Skip to content

Commit

Permalink
Fix launching settings when opening second instance
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-james-watson committed Oct 31, 2024
1 parent f24c09b commit 48f2a6f
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions app/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,18 @@ import { setAutoLauch } from "./lib/auto-launch";
import { initBreaks } from "./lib/breaks";
import "./lib/ipc";
import { showNotification } from "./lib/notifications";
import {
getAppInitialized,
setAppInitialized,
setBreaksEnabled
} from "./lib/store";
import { getAppInitialized, setAppInitialized } from "./lib/store";
import { initTray } from "./lib/tray";
import { createSettingsWindow, createSoundsWindow } from "./lib/windows";

const gotTheLock = app.requestSingleInstanceLock();

if (!gotTheLock) {
const cliArg = process.argv[process.argv.length - 1];

if (cliArg === "disable") {
console.log("breaks disabled");
setBreaksEnabled(false);
} else if (cliArg === "enable") {
console.log("breaks enabled");
setBreaksEnabled(true);
} else {
console.log("app already open, opening settings");
createSettingsWindow();
}
app.on("second-instance", () => {
createSettingsWindow();
});

if (!gotTheLock) {
log.info("app already running");
app.exit();
}

Expand Down

0 comments on commit 48f2a6f

Please sign in to comment.