diff options
author | André Oliveira <37463445+SpecialAro@users.noreply.github.com> | 2022-06-03 19:56:48 -0500 |
---|---|---|
committer | Vijay A <vraravam@users.noreply.github.com> | 2022-06-03 19:56:48 -0500 |
commit | e14df85e39a27944fdc4d5aecf084a68d7fd00c2 (patch) | |
tree | da474d4dabb98026354dc1ab75c90ff6da1ab3ef /src/index.ts | |
parent | 6.0.0-nightly.52 [skip ci] (diff) | |
download | ferdium-app-e14df85e39a27944fdc4d5aecf084a68d7fd00c2.tar.gz ferdium-app-e14df85e39a27944fdc4d5aecf084a68d7fd00c2.tar.zst ferdium-app-e14df85e39a27944fdc4d5aecf084a68d7fd00c2.zip |
Enable AutoUpdates from in-app with self-sign certificates on macOS (#213)
Co-authored-by: Alphrag <alphrag@pm.me>
Diffstat (limited to 'src/index.ts')
-rw-r--r-- | src/index.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/index.ts b/src/index.ts index 59a90a3cb..fad6b9b69 100644 --- a/src/index.ts +++ b/src/index.ts | |||
@@ -15,6 +15,7 @@ import { join } from 'path'; | |||
15 | import windowStateKeeper from 'electron-window-state'; | 15 | import windowStateKeeper from 'electron-window-state'; |
16 | import minimist from 'minimist'; | 16 | import minimist from 'minimist'; |
17 | import ms from 'ms'; | 17 | import ms from 'ms'; |
18 | import { EventEmitter } from 'events'; | ||
18 | import { enableWebContents, initializeRemote } from './electron-util'; | 19 | import { enableWebContents, initializeRemote } from './electron-util'; |
19 | import { enforceMacOSAppLocation } from './enforce-macos-app-location'; | 20 | import { enforceMacOSAppLocation } from './enforce-macos-app-location'; |
20 | 21 | ||
@@ -56,6 +57,9 @@ app.userAgentFallback = userAgent(); | |||
56 | // be closed automatically when the JavaScript object is garbage collected. | 57 | // be closed automatically when the JavaScript object is garbage collected. |
57 | let mainWindow: BrowserWindow | undefined; | 58 | let mainWindow: BrowserWindow | undefined; |
58 | let willQuitApp = false; | 59 | let willQuitApp = false; |
60 | let overrideAppQuitForUpdate = false; | ||
61 | |||
62 | export const appEvents = new EventEmitter(); | ||
59 | 63 | ||
60 | // Register methods to be called once the window has been loaded. | 64 | // Register methods to be called once the window has been loaded. |
61 | let onDidLoadFns: any[] | null = []; | 65 | let onDidLoadFns: any[] | null = []; |
@@ -320,7 +324,8 @@ const createWindow = () => { | |||
320 | debug('Window: hide'); | 324 | debug('Window: hide'); |
321 | mainWindow?.hide(); | 325 | mainWindow?.hide(); |
322 | } | 326 | } |
323 | } else { | 327 | } else if (!overrideAppQuitForUpdate) { |
328 | debug('Quitting the app'); | ||
324 | dbus.stop(); | 329 | dbus.stop(); |
325 | app.quit(); | 330 | app.quit(); |
326 | } | 331 | } |
@@ -653,12 +658,20 @@ app.on('window-all-closed', () => { | |||
653 | ) | 658 | ) |
654 | ) { | 659 | ) { |
655 | debug('Window: all windows closed, quit app'); | 660 | debug('Window: all windows closed, quit app'); |
656 | app.quit(); | 661 | if (!overrideAppQuitForUpdate) { |
662 | // TODO: based on https://github.com/electron-userland/electron-builder/issues/6058#issuecomment-1130344017 (not yet tested since we don't have signed builds yet for macos) | ||
663 | app.quit(); | ||
664 | } | ||
657 | } else { | 665 | } else { |
658 | debug("Window: don't quit app"); | 666 | debug("Window: don't quit app"); |
659 | } | 667 | } |
660 | }); | 668 | }); |
661 | 669 | ||
670 | appEvents.on('install-update', () => { | ||
671 | willQuitApp = true; | ||
672 | overrideAppQuitForUpdate = true; | ||
673 | }); | ||
674 | |||
662 | app.on('before-quit', event => { | 675 | app.on('before-quit', event => { |
663 | const yesButtonIndex = 0; | 676 | const yesButtonIndex = 0; |
664 | let selection = yesButtonIndex; | 677 | let selection = yesButtonIndex; |