Skip to content

Commit 5371946

Browse files
committed
Make riot desktop single instance
So launching a new instance will focus the old one, meaning that if you have Riot minimised to the tray and launch it via the desktop shortcut / start menu, you don't end up with more & more copies of the app. This doesn't really prevent you from running multiple copies of the app to fake multi account support since they share a data directory anyway.
1 parent 61c5253 commit 5371946

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎electron/src/electron-main.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ electron.ipcMain.on('install_update', installUpdate);
159159

160160
electron.app.commandLine.appendSwitch('--enable-usermedia-screen-capturing');
161161

162+
const shouldQuit = electron.app.makeSingleInstance((commandLine, workingDirectory) => {
163+
// Someone tried to run a second instance, we should focus our window.
164+
if (mainWindow) {
165+
if (!mainWindow.isVisible()) mainWindow.show();
166+
if (mainWindow.isMinimized()) mainWindow.restore();
167+
mainWindow.focus();
168+
}
169+
});
170+
171+
if (shouldQuit) {
172+
electron.app.quit()
173+
}
174+
162175
electron.app.on('ready', () => {
163176
if (vectorConfig.update_base_url) {
164177
console.log("Starting auto update with base URL: " + vectorConfig.update_base_url);

0 commit comments

Comments
 (0)