fix mac instance reloading
also consolidated restore function
This commit is contained in:
		
							parent
							
								
									8b4b69e2b4
								
							
						
					
					
						commit
						b3e0d2e5b2
					
				
					 2 changed files with 11 additions and 9 deletions
				
			
		|  | @ -11,7 +11,7 @@ import { autoUpdater } from "electron-updater"; | ||||||
| 
 | 
 | ||||||
| import { DATA_DIR } from "./constants"; | import { DATA_DIR } from "./constants"; | ||||||
| import { createFirstLaunchTour } from "./firstLaunch"; | import { createFirstLaunchTour } from "./firstLaunch"; | ||||||
| import { createWindows, mainWin } from "./mainWindow"; | import { createWindows, restoreVesktop } from "./mainWindow"; | ||||||
| import { registerMediaPermissionsHandler } from "./mediaPermissions"; | import { registerMediaPermissionsHandler } from "./mediaPermissions"; | ||||||
| import { registerScreenShareHandler } from "./screenShare"; | import { registerScreenShareHandler } from "./screenShare"; | ||||||
| import { Settings, State } from "./settings"; | import { Settings, State } from "./settings"; | ||||||
|  | @ -69,12 +69,7 @@ function init() { | ||||||
|     if (isDeckGameMode) nativeTheme.themeSource = "dark"; |     if (isDeckGameMode) nativeTheme.themeSource = "dark"; | ||||||
| 
 | 
 | ||||||
|     app.on("second-instance", (_event, _cmdLine, _cwd, data: any) => { |     app.on("second-instance", (_event, _cmdLine, _cwd, data: any) => { | ||||||
|         if (data.IS_DEV) app.quit(); |         data.IS_DEV ? app.quit() : restoreVesktop(); | ||||||
|         else if (mainWin) { |  | ||||||
|             if (mainWin.isMinimized()) mainWin.restore(); |  | ||||||
|             if (!mainWin.isVisible()) mainWin.show(); |  | ||||||
|             mainWin.focus(); |  | ||||||
|         } |  | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     app.whenReady().then(async () => { |     app.whenReady().then(async () => { | ||||||
|  |  | ||||||
|  | @ -465,16 +465,23 @@ function createMainWindow() { | ||||||
| 
 | 
 | ||||||
|     let uriFiredDarwin = false; |     let uriFiredDarwin = false; | ||||||
|     app.on("open-url", (_, url) => { |     app.on("open-url", (_, url) => { | ||||||
|  |         uriFiredDarwin ? restoreVesktop() : loadUrl(url); | ||||||
|         uriFiredDarwin = true; |         uriFiredDarwin = true; | ||||||
|         loadUrl(url); |  | ||||||
|     }); |     }); | ||||||
|     uriFiredDarwin || loadUrl(uri); |     uriFiredDarwin || loadUrl(uri); | ||||||
| 
 |  | ||||||
|     return win; |     return win; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDesktopMain.js"))); | const runVencordMain = once(() => require(join(VENCORD_FILES_DIR, "vencordDesktopMain.js"))); | ||||||
| 
 | 
 | ||||||
|  | export function restoreVesktop() { | ||||||
|  |     if (mainWin) { | ||||||
|  |         if (mainWin.isMinimized()) mainWin.restore(); | ||||||
|  |         if (!mainWin.isVisible()) mainWin.show(); | ||||||
|  |         mainWin.focus(); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
| export async function createWindows() { | export async function createWindows() { | ||||||
|     const startMinimized = process.argv.includes("--start-minimized"); |     const startMinimized = process.argv.includes("--start-minimized"); | ||||||
|     const splash = createSplashWindow(startMinimized); |     const splash = createSplashWindow(startMinimized); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Kylie C
						Kylie C