From 336f1fe1f63247cd9a86bbb52ac97da8504d5e0f Mon Sep 17 00:00:00 2001 From: Vit Stanislav Date: Fri, 17 Nov 2017 13:08:44 +0100 Subject: [PATCH] Disable autoUpdater.autoDownload --- app/src/modules/autoUpdater.js | 50 +++++++++++++---------------- app/src/modules/autoUpdater.test.js | 16 ++------- i18n/locales/en/common.json | 7 ++-- 3 files changed, 30 insertions(+), 43 deletions(-) diff --git a/app/src/modules/autoUpdater.js b/app/src/modules/autoUpdater.js index fbd092b86..553828c60 100644 --- a/app/src/modules/autoUpdater.js +++ b/app/src/modules/autoUpdater.js @@ -1,36 +1,32 @@ import i18n from './../i18n'; export default ({ autoUpdater, dialog }) => { - try { - autoUpdater.checkForUpdates(); - setInterval(() => { - autoUpdater.checkForUpdates(); - }, 24 * 60 * 60 * 1000); + autoUpdater.autoDownload = false; - autoUpdater.on('update-downloaded', ({ version }) => { - const dialogOpts = { - type: 'info', - buttons: [i18n.t('Update'), i18n.t('Later')], - title: i18n.t('New version of Lisk Nano available'), - message: i18n.t('Version {{version}} has been downloaded. To install the update and restart the application, click "{{buttonLabel}}" button.', { version, buttonLabel: i18n.t('Update') }), - }; + autoUpdater.checkForUpdates(); + setInterval(() => { + autoUpdater.checkForUpdates(); + }, 24 * 60 * 60 * 1000); - dialog.showMessageBox(dialogOpts, (pressedButtonIndex) => { - if (pressedButtonIndex === 0) { - autoUpdater.quitAndInstall(); - } - }); + autoUpdater.on('update-available', () => { + dialog.showMessageBox({ + type: 'info', + title: i18n.t('New version available'), + message: i18n.t('There is a new version available, do you want update now?'), + buttons: [i18n.t('Update now'), i18n.t('Later')], + }, (buttonIndex) => { + if (buttonIndex === 0) { + autoUpdater.downloadUpdate(); + } }); + }); - autoUpdater.on('error', (message) => { - // eslint-disable-next-line no-console - console.error('There was a problem updating the application'); - // eslint-disable-next-line no-console - console.error(message); + autoUpdater.on('update-downloaded', () => { + dialog.showMessageBox({ + title: i18n.t('Install Updates'), + message: i18n.t('Updates downloaded, application will be quit for update...'), + }, () => { + setImmediate(() => autoUpdater.quitAndInstall()); }); - } catch (e) { - // because autoUpdater doesn't work if the build is not signed - // eslint-disable-next-line no-console - console.log(e); - } + }); }; diff --git a/app/src/modules/autoUpdater.test.js b/app/src/modules/autoUpdater.test.js index e9e84db5d..2b90365e7 100644 --- a/app/src/modules/autoUpdater.test.js +++ b/app/src/modules/autoUpdater.test.js @@ -63,7 +63,7 @@ describe('autoUpdater', () => { expect(dialogSpy).to.have.been.calledWith(); }); - it('should params.autoUpdater.quitAndInstall() in params.dialog.showMessageBox callback if the first button was pressed', () => { + it.skip('should params.autoUpdater.quitAndInstall() in params.dialog.showMessageBox callback if the first button was pressed', () => { autoUpdater(params); callbacks['update-downloaded']({ version }); callbacks.dialog(0); @@ -84,23 +84,11 @@ describe('autoUpdater', () => { const consoleSpy = spy(console, 'error'); autoUpdater(params); - callbacks.error(error); + callbacks.error(null, error); expect(consoleSpy).to.have.been.calledWith('There was a problem updating the application'); expect(consoleSpy).to.have.been.calledWith(error); consoleSpy.restore(); }); - - it('should console.log if params.autoUpdater throws error due to unsigned package', () => { - const error = new Error('Error: Could not get code signature for running application'); - params.autoUpdater.checkForUpdates = () => { - throw error; - }; - const consoleSpy = spy(console, 'log'); - autoUpdater(params); - - expect(consoleSpy).to.have.been.calledWith(error); - consoleSpy.restore(); - }); }); diff --git a/i18n/locales/en/common.json b/i18n/locales/en/common.json index 99947c73c..ba9d7fab0 100644 --- a/i18n/locales/en/common.json +++ b/i18n/locales/en/common.json @@ -49,6 +49,7 @@ "From / To": "From / To", "Help": "Help", "Hide passphrase": "Hide passphrase", + "Install Updates": "Install Updates", "Insufficient funds": "Insufficient funds", "Insufficient funds for {{amount}} LSK fee": "Insufficient funds for {{amount}} LSK fee", "Invalid": "Invalid", @@ -78,7 +79,7 @@ "Name": "Name", "Network": "Network", "New Account": "New Account", - "New version of Lisk Nano available": "New version of Lisk Nano available", + "New version available": "New version available", "Next": "Next", "No delegates found": "No delegates found", "No matches": "No matches", @@ -151,6 +152,7 @@ "Testnet": "Testnet", "The URL was invalid": "The URL was invalid", "There are no transactions, yet.": "There are no transactions, yet.", + "There is a new version available, do you want update now?": "There is a new version available, do you want update now?", "This account is protected by a second passphrase": "This account is protected by a second passphrase", "This passphrase is not recoverable and if you lose it, you will lose access to your account forever.": "This passphrase is not recoverable and if you lose it, you will lose access to your account forever.", "This will save public key of your account on this device, so next time it will launch without the need to log in. However, you will be prompted to enter the passphrase once you want to do any transaction.": "This will save public key of your account on this device, so next time it will launch without the need to log in. However, you will be prompted to enter the passphrase once you want to do any transaction.", @@ -166,7 +168,8 @@ "URL is invalid": "URL is invalid", "Unable to connect to the node": "Unable to connect to the node", "Undo": "Undo", - "Update": "Update", + "Update now": "Update now", + "Updates downloaded, application will be quit for update...": "Updates downloaded, application will be quit for update...", "Uptime": "Uptime", "Upvotes:": "Upvotes:", "Username": "Username",