diff --git a/src/main/index.ts b/src/main/index.ts index 4df2ad7..0666fc1 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -11,7 +11,7 @@ import { autoUpdater } from "electron-updater"; import { DATA_DIR } from "./constants"; import { createFirstLaunchTour } from "./firstLaunch"; -import { createWindows, mainWin } from "./mainWindow"; +import { createWindows, restoreVesktop } from "./mainWindow"; import { registerMediaPermissionsHandler } from "./mediaPermissions"; import { registerScreenShareHandler } from "./screenShare"; import { Settings, State } from "./settings"; @@ -69,12 +69,7 @@ function init() { if (isDeckGameMode) nativeTheme.themeSource = "dark"; app.on("second-instance", (_event, _cmdLine, _cwd, data: any) => { - if (data.IS_DEV) app.quit(); - else if (mainWin) { - if (mainWin.isMinimized()) mainWin.restore(); - if (!mainWin.isVisible()) mainWin.show(); - mainWin.focus(); - } + data.IS_DEV ? app.quit() : restoreVesktop(); }); app.whenReady().then(async () => { diff --git a/src/main/mainWindow.ts b/src/main/mainWindow.ts index 4ff7e8c..59ea2c7 100644 --- a/src/main/mainWindow.ts +++ b/src/main/mainWindow.ts @@ -465,16 +465,23 @@ function createMainWindow() { let uriFiredDarwin = false; app.on("open-url", (_, url) => { + uriFiredDarwin ? restoreVesktop() : loadUrl(url); uriFiredDarwin = true; - loadUrl(url); }); uriFiredDarwin || loadUrl(uri); - return win; } 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() { const startMinimized = process.argv.includes("--start-minimized"); const splash = createSplashWindow(startMinimized);