From e934617a03479ed754ec368fce0b90b30882691d Mon Sep 17 00:00:00 2001 From: s2 Date: Sun, 13 Sep 2020 12:48:05 +0200 Subject: [PATCH] ask if the update should be downloaded --- app/js/index.js | 20 +++++++++++++++----- app/main.js | 8 ++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/js/index.js b/app/js/index.js index b93fa780..d57ec286 100644 --- a/app/js/index.js +++ b/app/js/index.js @@ -13,15 +13,18 @@ //update stuff ipcRenderer.on('update', (event, state) => { if (state.event === 'updateAvailable') { - $('.js-updatenotice').text(`New version ${state.version} available. Downloading...`); - $('.js-updatenotice').prop('disabled', true); + $('.js-updatenotice').text(`New version ${state.version} available. Click here to download.`); $('.js-updatenotice').show(); + $('.js-updatenotice').prop('disabled', false); + $('.js-updatenotice').prop('state', 'ready-to-download'); + $('.js-updatenotice').data('asset', state.asset); } if (state.event === 'updateReadyToInstall') { $('.js-updatenotice').text(`New version ready to install. Click here to start installer.`); $('.js-updatenotice').show(); $('.js-updatenotice').prop('disabled', false); + $('.js-updatenotice').prop('state', 'ready-to-install'); $('.js-updatenotice').data('file', state.file); } }); @@ -31,9 +34,16 @@ if ($('.js-updatenotice').prop('disabled')) { return; } - $('.js-updatenotice').prop('disabled', true); - $('.js-updatenotice').text(`Launching installer...`); - ipcRenderer.send('installUpdate', $('.js-updatenotice').data('file')); + + if ($('.js-updatenotice').prop('state') === 'ready-to-download') { + $('.js-updatenotice').prop('disabled', true); + $('.js-updatenotice').text(`Downloading new version...`); + ipcRenderer.send('downloadUpdate', $('.js-updatenotice').data('asset')); + } else if ($('.js-updatenotice').prop('state') === 'ready-to-install') { + $('.js-updatenotice').prop('disabled', true); + $('.js-updatenotice').text(`Launching installer...`); + ipcRenderer.send('installUpdate', $('.js-updatenotice').data('file')); + } }); //end update stuff diff --git a/app/main.js b/app/main.js index 1a3a6ee1..f3285ceb 100644 --- a/app/main.js +++ b/app/main.js @@ -26,9 +26,9 @@ if (process.platform === 'win32') { gau.onUpdateAvailable = (version, asset) => { win.webContents.send('update', { event: 'updateAvailable', - version: version + version: version, + asset: asset }); - gau.downloadNewVersion(asset); }; gau.onNewVersionReadyToInstall = (file) => { @@ -38,6 +38,10 @@ if (process.platform === 'win32') { }); }; + ipcMain.on('downloadUpdate', (event, asset) => { + gau.downloadNewVersion(asset); + }); + ipcMain.on('installUpdate', (event, file) => { gau.executeUpdate(file); win.webContents.send('update', {