Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Disable autoUpdater.autoDownload
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Nov 17, 2017
1 parent 1ad7346 commit 336f1fe
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 43 deletions.
50 changes: 23 additions & 27 deletions app/src/modules/autoUpdater.js
Original file line number Diff line number Diff line change
@@ -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);
}
});
};
16 changes: 2 additions & 14 deletions app/src/modules/autoUpdater.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
});
});

7 changes: 5 additions & 2 deletions i18n/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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.",
Expand All @@ -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",
Expand Down

0 comments on commit 336f1fe

Please sign in to comment.