Prevent multiple downloads when auto updater isn't supported. Hide upgrade nag when on progress modal is displayed.
This commit is contained in:
parent
40e20dfc1b
commit
64a2e908ae
2 changed files with 16 additions and 3 deletions
|
@ -43,12 +43,19 @@ let autoUpdateDownloaded = false;
|
|||
// that we show on Windows after you decline an upgrade and close the app later.
|
||||
let showingAutoUpdateCloseAlert = false;
|
||||
|
||||
// This is used to prevent downloading updates multiple times.
|
||||
// This is used to prevent downloading updates multiple times when
|
||||
// using the auto updater API.
|
||||
// As read in the documentation:
|
||||
// "Calling autoUpdater.checkForUpdates() twice will download the update two times."
|
||||
// https://www.electronjs.org/docs/latest/api/auto-updater#autoupdatercheckforupdates
|
||||
let keepCheckingForUpdates = true;
|
||||
|
||||
// Auto updater doesn't support Linux installations (only trough AppImages)
|
||||
// this is why, for that case, we download a full executable (.deb package)
|
||||
// as a fallback support. This variable will be used to prevent
|
||||
// multiple downloads when auto updater isn't supported.
|
||||
let downloadUpgradeInProgress = false;
|
||||
|
||||
// Keep a global reference, if you don't, they will be closed automatically when the JavaScript
|
||||
// object is garbage collected.
|
||||
let rendererWindow;
|
||||
|
@ -321,6 +328,10 @@ ipcMain.on('get-disk-space', async (event) => {
|
|||
});
|
||||
|
||||
ipcMain.on('download-upgrade', async (event, params) => {
|
||||
if (downloadUpgradeInProgress) {
|
||||
return;
|
||||
}
|
||||
|
||||
const { url, options } = params;
|
||||
const dir = fs.mkdtempSync(app.getPath('temp') + path.sep);
|
||||
options.onProgress = function(p) {
|
||||
|
@ -328,9 +339,11 @@ ipcMain.on('download-upgrade', async (event, params) => {
|
|||
};
|
||||
options.directory = dir;
|
||||
options.onCompleted = function(c) {
|
||||
downloadUpgradeInProgress = false;
|
||||
rendererWindow.webContents.send('download-update-complete', c);
|
||||
};
|
||||
const win = BrowserWindow.getFocusedWindow();
|
||||
downloadUpgradeInProgress = true;
|
||||
await download(win, url, options).catch(e => console.log('e', e));
|
||||
});
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { createSelector } from 'reselect';
|
||||
import { selectClaimsById, selectMyChannelClaims, selectTotalStakedAmountForChannelUri } from 'redux/selectors/claims';
|
||||
import { AUTO_UPDATE_DOWNLOADED } from 'constants/modal_types';
|
||||
import * as MODALS from 'constants/modal_types';
|
||||
|
||||
export const selectState = (state) => state.app || {};
|
||||
|
||||
|
@ -53,7 +53,7 @@ export const selectAutoUpdateDownloaded = createSelector(selectState, (state) =>
|
|||
export const selectAutoUpdateDeclined = createSelector(selectState, (state) => state.autoUpdateDeclined);
|
||||
|
||||
export const selectIsUpdateModalDisplayed = createSelector(selectState, (state) => {
|
||||
return state.modal === AUTO_UPDATE_DOWNLOADED;
|
||||
return [MODALS.AUTO_UPDATE_DOWNLOADED, MODALS.UPGRADE, MODALS.DOWNLOADING].includes(state.modal);
|
||||
});
|
||||
|
||||
export const selectDaemonVersionMatched = createSelector(selectState, (state) => state.daemonVersionMatched);
|
||||
|
|
Loading…
Reference in a new issue