Await moveToApplicationsFolder invocation on main process

This commit is contained in:
Sergio Padrino 2022-02-15 12:22:32 +01:00
parent ab48d526da
commit fa75ab567d
5 changed files with 7 additions and 6 deletions

View file

@ -72,7 +72,6 @@ export type RequestChannels = {
'auto-updater-update-downloaded': () => void
'native-theme-updated': () => void
'set-native-theme-source': (themeName: ThemeSource) => void
'move-to-applications-folder': () => void
'focus-window': () => void
}
@ -97,6 +96,7 @@ export type RequestResponseChannels = {
'is-window-focused': () => Promise<boolean>
'open-external': (path: string) => Promise<boolean>
'is-in-application-folder': () => Promise<boolean | null>
'move-to-applications-folder': () => Promise<void>
'check-for-updates': (url: string) => Promise<Error | undefined>
'get-current-window-state': () => Promise<WindowState | undefined>
'get-current-window-zoom-factor': () => Promise<number | undefined>

View file

@ -576,7 +576,7 @@ app.on('ready', () => {
* An event sent by the renderer asking to move the app to the application
* folder
*/
ipcMain.on('move-to-applications-folder', () => {
ipcMain.handle('move-to-applications-folder', async () => {
app.moveToApplicationsFolder?.()
})

View file

@ -1375,8 +1375,9 @@ export class Dispatcher {
return this.appStore.setStatsOptOut(optOut, userViewedPrompt)
}
/** Moves the app to the /Applications folder on macOS. */
public moveToApplicationsFolder() {
moveToApplicationsFolder()
return moveToApplicationsFolder()
}
/**

View file

@ -217,7 +217,7 @@ export function sendWillQuitSync() {
/**
* Tell the main process to move the application to the application folder
*/
export const moveToApplicationsFolder = sendProxy(
export const moveToApplicationsFolder = invokeProxy(
'move-to-applications-folder',
0
)

View file

@ -97,11 +97,11 @@ export class MoveToApplicationsFolder extends React.Component<
)
}
private onSubmit = () => {
private onSubmit = async () => {
this.props.onDismissed()
try {
this.props.dispatcher.moveToApplicationsFolder()
await this.props.dispatcher.moveToApplicationsFolder()
} catch (error) {
this.props.dispatcher.postError(error)
}