@@ -60,34 +60,47 @@ const createWindow = () => {
6060 } ) ;
6161} ;
6262
63- app . whenReady ( ) . then ( ( ) => {
64- ensureEnv ( ) ;
63+ const gotTheLock = app . requestSingleInstanceLock ( ) ;
6564
66- // Subscribing to the listeners happens even before creating the window to be ready to actively respond to initial events coming from renderer.
67- initListeners ( ) ;
65+ if ( ! gotTheLock ) {
66+ app . quit ( ) ;
67+ } else {
68+ app . on ( "second-instance" , ( ) => {
69+ if ( win ) {
70+ if ( win . isMinimized ( ) ) win . restore ( ) ;
71+ win . focus ( ) ;
72+ }
73+ } ) ;
6874
69- createWindow ( ) ;
75+ app . whenReady ( ) . then ( ( ) => {
76+ ensureEnv ( ) ;
7077
71- if ( envIs ( "development" ) ) {
72- setupDevelopmentWorkflow ( ) ;
73- devLog ( "Development setup done" ) ;
74- }
78+ // Subscribing to the listeners happens even before creating the window to be ready to actively respond to initial events coming from renderer.
79+ initListeners ( ) ;
80+
81+ createWindow ( ) ;
82+
83+ if ( envIs ( "development" ) ) {
84+ setupDevelopmentWorkflow ( ) ;
85+ devLog ( "Development setup done" ) ;
86+ }
7587
76- initRateLimiter ( ) ;
88+ initRateLimiter ( ) ;
7789
78- win . webContents . on ( "did-finish-load" , ( ) => {
79- win . setTitle ( windows . MAIN ) ;
90+ win . webContents . on ( "did-finish-load" , ( ) => {
91+ win . setTitle ( windows . MAIN ) ;
92+ } ) ;
8093 } ) ;
81- } ) ;
8294
83- app . on ( "window-all-closed" , ( ) => {
84- if ( process . platform !== "darwin" ) {
85- app . quit ( ) ;
86- }
87- } ) ;
95+ app . on ( "window-all-closed" , ( ) => {
96+ if ( process . platform !== "darwin" ) {
97+ app . quit ( ) ;
98+ }
99+ } ) ;
88100
89- app . on ( "activate" , ( ) => {
90- if ( win === null ) {
91- createWindow ( ) ;
92- }
93- } ) ;
101+ app . on ( "activate" , ( ) => {
102+ if ( win === null ) {
103+ createWindow ( ) ;
104+ }
105+ } ) ;
106+ }
0 commit comments