@@ -100,24 +100,12 @@ ipcMain.on('app_onAction', function(ev, payload) {
100100
101101app . commandLine . appendSwitch ( '--enable-usermedia-screen-capturing' ) ;
102102
103- const shouldQuit = app . makeSingleInstance ( ( commandLine , workingDirectory ) => {
104- // If other instance launched with --hidden then skip showing window
105- if ( commandLine . includes ( '--hidden' ) ) return ;
106-
107- // Someone tried to run a second instance, we should focus our window.
108- if ( mainWindow ) {
109- if ( ! mainWindow . isVisible ( ) ) mainWindow . show ( ) ;
110- if ( mainWindow . isMinimized ( ) ) mainWindow . restore ( ) ;
111- mainWindow . focus ( ) ;
112- }
113- } ) ;
114-
115- if ( shouldQuit ) {
103+ const gotLock = app . requestSingleInstanceLock ( ) ;
104+ if ( ! gotLock ) {
116105 console . log ( 'Other instance detected: exiting' ) ;
117106 app . exit ( ) ;
118107}
119108
120-
121109const launcher = new AutoLaunch ( {
122110 name : vectorConfig . brand || 'Riot' ,
123111 isHidden : true ,
@@ -268,6 +256,18 @@ app.on('before-quit', () => {
268256 }
269257} ) ;
270258
259+ app . on ( 'second-instance' , ( ev , commandLine , workingDirectory ) => {
260+ // If other instance launched with --hidden then skip showing window
261+ if ( commandLine . includes ( '--hidden' ) ) return ;
262+
263+ // Someone tried to run a second instance, we should focus our window.
264+ if ( mainWindow ) {
265+ if ( ! mainWindow . isVisible ( ) ) mainWindow . show ( ) ;
266+ if ( mainWindow . isMinimized ( ) ) mainWindow . restore ( ) ;
267+ mainWindow . focus ( ) ;
268+ }
269+ } ) ;
270+
271271// Set the App User Model ID to match what the squirrel
272272// installer uses for the shortcut icon.
273273// This makes notifications work on windows 8.1 (and is
0 commit comments