From d44ae0dce87f29bb6596199e021901c967a0893d Mon Sep 17 00:00:00 2001 From: ThaUnknown <6506529+ThaUnknown@users.noreply.github.com> Date: Wed, 3 Jul 2024 21:09:41 +0200 Subject: [PATCH] fix: macOS updater --- common/modules/rss.js | 4 ++-- electron/src/main/app.js | 2 +- electron/src/main/updater.js | 9 +++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/common/modules/rss.js b/common/modules/rss.js index b145357..5c608f6 100644 --- a/common/modules/rss.js +++ b/common/modules/rss.js @@ -69,9 +69,9 @@ class RSSMediaManager { if (!ignoreErrors) { res.catch(e => { toast.error('Search Failed', { - description: 'Failed Loading Media for Home Feed!\n' + e.message + description: 'Failed to loading media for home feed!\n' + e.message }) - console.error('Failed Loading Media for Home Feed', e) + console.error('Failed to loading media for home feed', e) }) } return Array.from({ length: perPage }, (_, i) => ({ type: 'episode', data: this.fromPending(res, i) })) diff --git a/electron/src/main/app.js b/electron/src/main/app.js index 1697342..8f8cc81 100644 --- a/electron/src/main/app.js +++ b/electron/src/main/app.js @@ -146,6 +146,6 @@ export default class App { setTimeout(resolve, 5000).unref?.() }) this.destroyed = true - app.quit() + if (!this.updater.install()) app.quit() } } diff --git a/electron/src/main/updater.js b/electron/src/main/updater.js index ba20f51..a869281 100644 --- a/electron/src/main/updater.js +++ b/electron/src/main/updater.js @@ -10,6 +10,7 @@ ipcMain.on('update', () => { autoUpdater.checkForUpdatesAndNotify() export default class Updater { + hasUpdate = false /** * @param {import('electron').BrowserWindow} window */ @@ -18,7 +19,15 @@ export default class Updater { window.webContents.send('update-available', true) }) autoUpdater.on('update-downloaded', () => { + this.hasUpdate = true window.webContents.send('update-downloaded', true) }) } + + install () { + if (this.hasUpdate) { + autoUpdater.quitAndInstall() + return true + } + } }