Skip to content

Commit

Permalink
feat: detect multiple instances
Browse files Browse the repository at this point in the history
  • Loading branch information
3Shain committed Mar 8, 2023
1 parent 6884cf3 commit 614d0c6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import {
prompt,
addTerminationHook,
GLOBAL_onClose,
getKey,
setKey,
alert,
} from "./utils";
import { createAria2 } from "./aria2";
import { checkWine, createWine, createWineInstallProgram } from "./wine";
Expand All @@ -20,6 +23,15 @@ import { createUpdater, downloadProgram } from "./updater";
import { createCommonUpdateUI } from "./common-update-ui";

export async function createApp() {
try {
await getKey("singleton");
await alert("NOTE", "LAUNCHER_ALREADY_EXISTS");
Neutralino.app.exit(0);
return () => null;
} catch {
await setKey("singleton", "1");
}

let aria2_port = 6868;

await Neutralino.events.on("ready", async () => {});
Expand Down
5 changes: 4 additions & 1 deletion src/utils/neu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,10 @@ export async function stats(path: string) {
return await Neutralino.filesystem.getStats(path);
}

const hooks: Array<(forced: boolean) => Promise<boolean>> = [];
const hooks: Array<(forced: boolean) => Promise<boolean>> = [async ()=>{
await setKey("singleton", null);
return true;
}];

export function addTerminationHook(fn: (forced: boolean) => Promise<boolean>) {
hooks.push(fn);
Expand Down

0 comments on commit 614d0c6

Please sign in to comment.