forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlifecycle.ts
More file actions
28 lines (23 loc) · 923 Bytes
/
Copy pathlifecycle.ts
File metadata and controls
28 lines (23 loc) · 923 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Single source of truth for "the app is really quitting" vs "a window is just
// hiding to the tray". Every close-to-tray decision (main window close, overlay
// close) reads isQuitting(); every real-quit path (tray Quit, Ctrl+Q, the
// app:quit IPC, before-quit) sets it. Consolidated here so the flag can't drift
// between windows.
import { app } from 'electron'
let quitting = false
export function isQuitting(): boolean {
return quitting
}
/** Mark the app as quitting. Idempotent. */
export function markQuitting(): void {
quitting = true
}
/** Quit for real: set the flag first so close handlers don't preventDefault. */
export function quitApp(): void {
markQuitting()
app.quit()
}
// Any path into shutdown (menu quit, OS logoff, autoUpdater install-on-quit)
// funnels through before-quit; make sure the flag is set even for paths that
// didn't call quitApp().
app.on('before-quit', markQuitting)