diff --git a/src/main/index.ts b/src/main/index.ts index f5f63bd22..f7f125ea7 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -18,7 +18,6 @@ import { type IOpenExternal, } from '../shared/events'; import { logInfo, logWarn } from '../shared/logger'; -import { isLinux, isWindows } from '../shared/platform'; import { handleMainEvent, onMainEvent, sendRendererEvent } from './events'; import { onFirstRunMaybe } from './first-run'; @@ -78,6 +77,8 @@ let shouldUseAlternateIdleIcon = false; let shouldUseUnreadActiveIcon = true; app.whenReady().then(async () => { + preventSecondInstance(); + await onFirstRunMaybe(); appUpdater.start(); @@ -116,31 +117,6 @@ app.whenReady().then(async () => { }); }); - /** Prevent second instances */ - if (isWindows() || isLinux()) { - const gotTheLock = app.requestSingleInstanceLock(); - - if (!gotTheLock) { - logWarn('main:gotTheLock', 'Second instance detected, quitting'); - app.quit(); // Quit the second instance - return; - } - - app.on('second-instance', (_event, commandLine, _workingDirectory) => { - logInfo( - 'main:second-instance', - 'Second instance was launched. extracting command to forward', - ); - - // Get the URL from the command line arguments - const url = commandLine.find((arg) => arg.startsWith(`${protocol}://`)); - - if (url) { - handleURL(url); - } - }); - } - /** * Gitify custom IPC events - no response expected */ @@ -280,3 +256,30 @@ function setActiveIcon() { function setErrorIcon() { mb.tray.setImage(TrayIcons.error); } + +/** + * Prevent second instances + */ +function preventSecondInstance() { + const gotTheLock = app.requestSingleInstanceLock(); + + if (!gotTheLock) { + logWarn('main:gotTheLock', 'Second instance detected, quitting'); + app.quit(); // Quit the second instance + return; + } + + app.on('second-instance', (_event, commandLine, _workingDirectory) => { + logInfo( + 'main:second-instance', + 'Second instance was launched. extracting command to forward', + ); + + // Get the URL from the command line arguments + const url = commandLine.find((arg) => arg.startsWith(`${protocol}://`)); + + if (url) { + handleURL(url); + } + }); +}