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 { 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 () => {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue