diff --git a/assets/locales/en.json b/assets/locales/en.json index 9131c05c3..0cc80df56 100644 --- a/assets/locales/en.json +++ b/assets/locales/en.json @@ -129,14 +129,14 @@ "message": "It was not possible to download the update. Please check your Internet connection and try again." }, "updateDownloadedDialog": { - "title": "Update IPFS Desktop", + "title": "IPFS Desktop Update", "message": "An update to IPFS Desktop { version } is available. Would you like to install it now?", "later": "Later", "now": "Install now" }, "updateDownloadedNotification": { - "title": "Update downloaded", - "message": "Update for version { version } of IPFS Desktop downloaded." + "title": "IPFS Desktop Update", + "message": "An update to IPFS Desktop { version } is available." }, "runGarbageCollectorWarning": { "title": "Garbage collector", diff --git a/src/auto-updater/index.js b/src/auto-updater/index.js index b82390bb0..41401c3cb 100644 --- a/src/auto-updater/index.js +++ b/src/auto-updater/index.js @@ -1,9 +1,8 @@ -const { shell, app, BrowserWindow } = require('electron') +const { shell, app, BrowserWindow, Notification } = require('electron') const { autoUpdater } = require('electron-updater') const i18n = require('i18next') const { ipcMain } = require('electron') const logger = require('../common/logger') -const { notify } = require('../common/notify') const { showDialog } = require('../dialogs') const { IS_MAC, IS_WIN, IS_APPIMAGE } = require('../common/consts') @@ -90,29 +89,35 @@ function setup (ctx) { autoUpdater.on('update-downloaded', ({ version }) => { logger.info(`[updater] update to ${version} downloaded`) - if (!feedback) { - notify({ - title: i18n.t('updateDownloadedNotification.title'), - body: i18n.t('updateDownloadedNotification.message', { version }) + const feedbackDialog = () => { + const opt = showDialog({ + title: i18n.t('updateDownloadedDialog.title'), + message: i18n.t('updateDownloadedDialog.message', { version }), + type: 'info', + buttons: [ + i18n.t('updateDownloadedDialog.later'), + i18n.t('updateDownloadedDialog.now') + ] }) + if (opt === 1) { // now + setImmediate(async () => { + await beforeQuitCleanup() // just to be sure (we had regressions before) + autoUpdater.quitAndInstall() + }) + } } - - feedback = false - - const opt = showDialog({ - title: i18n.t('updateDownloadedDialog.title'), - message: i18n.t('updateDownloadedDialog.message', { version }), - type: 'info', - buttons: [ - i18n.t('updateDownloadedDialog.later'), - i18n.t('updateDownloadedDialog.now') - ] - }) - if (opt === 1) { // now - setImmediate(async () => { - await beforeQuitCleanup() // just to be sure (we had regressions before) - autoUpdater.quitAndInstall() + if (feedback) { + feedback = false + // when in instant feedback mode, show dialog immediatelly + feedbackDialog() + } else { + // show unobtrusive notification + dialog on click + const note = new Notification({ + title: i18n.t('updateDownloadedNotification.title'), + body: i18n.t('updateDownloadedNotification.message', { version }) }) + note.on('click', feedbackDialog) + note.show() } })