1
0
mirror of https://github.com/S2-/gitlit synced 2025-08-02 04:10:05 +02:00

ask if the update should be downloaded

This commit is contained in:
s2
2020-09-13 12:48:05 +02:00
parent 9f696e12f9
commit e934617a03
2 changed files with 21 additions and 7 deletions

View File

@@ -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

View File

@@ -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', {