Skip to content

Commit

Permalink
Expose an app restart API to the renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
pimterry committed Oct 24, 2024
1 parent 66e6875 commit 36610dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,4 +638,14 @@ ipcMain.handle('open-context-menu', ipcHandler((options: ContextMenuDefinition)
));

ipcMain.handle('get-desktop-version', ipcHandler(() => DESKTOP_VERSION));
ipcMain.handle('get-server-auth-token', ipcHandler(() => AUTH_TOKEN));
ipcMain.handle('get-server-auth-token', ipcHandler(() => AUTH_TOKEN));

let restarting = false;
ipcMain.handle('restart-app', ipcHandler(() => {
if (restarting) return;
restarting = true;
console.log('Restarting...');

app.relaunch();
app.quit();
}));
5 changes: 4 additions & 1 deletion src/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@ contextBridge.exposeInMainWorld('desktopApi', {
selectApplication: () =>
ipcRenderer.invoke('select-application'),
openContextMenu: (options: ContextMenuDefinition) =>
ipcRenderer.invoke('open-context-menu', options)
ipcRenderer.invoke('open-context-menu', options),

restartApp: () =>
ipcRenderer.invoke('restart-app')
});

0 comments on commit 36610dc

Please sign in to comment.