Skip to content

Commit

Permalink
feat: quit when another instance is already running
Browse files Browse the repository at this point in the history
  • Loading branch information
CodyTseng committed Oct 14, 2024
1 parent 141cf41 commit 2a2d341
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { electronApp, is } from '@electron-toolkit/utils'
import dayjs from 'dayjs'
import duration from 'dayjs/plugin/duration'
import { app, BrowserWindow, clipboard, ipcMain, Menu, nativeImage, shell, Tray } from 'electron'
import { BrowserWindow, Menu, Tray, app, clipboard, ipcMain, nativeImage, shell } from 'electron'
import { join } from 'path'
import icon from '../../build/icon.png?asset'
import nostrTemplate from '../../resources/nostrTemplate.png?asset'
Expand Down Expand Up @@ -29,6 +29,12 @@ let hubConnector: HubConnectorService
let tray: Tray | null = null
let mainWindow: BrowserWindow | null = null

const singleInstanceLock = app.requestSingleInstanceLock()
// Quit the app if another instance is already running
if (!singleInstanceLock) {
app.quit()
}

// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
Expand Down

0 comments on commit 2a2d341

Please sign in to comment.