mirror of
https://github.com/CringeStudios/element-desktop.git
synced 2025-01-18 23:44:59 +01:00
Merge pull request #98 from vector-im/t3chguy/remember-updates
Electron recall latest downloaded update for when the user manually asks
This commit is contained in:
commit
303a7f0bd0
@ -254,17 +254,6 @@ ipcMain.on('app_onAction', function(ev, payload) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
autoUpdater.on('update-downloaded', (ev, releaseNotes, releaseName, releaseDate, updateURL) => {
|
|
||||||
if (!mainWindow) return;
|
|
||||||
// forward to renderer
|
|
||||||
mainWindow.webContents.send('update-downloaded', {
|
|
||||||
releaseNotes,
|
|
||||||
releaseName,
|
|
||||||
releaseDate,
|
|
||||||
updateURL,
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
ipcMain.on('ipcCall', async function(ev, payload) {
|
ipcMain.on('ipcCall', async function(ev, payload) {
|
||||||
if (!mainWindow) return;
|
if (!mainWindow) return;
|
||||||
|
|
||||||
|
@ -69,15 +69,31 @@ ipcMain.on('install_update', installUpdate);
|
|||||||
ipcMain.on('check_updates', pollForUpdates);
|
ipcMain.on('check_updates', pollForUpdates);
|
||||||
|
|
||||||
function ipcChannelSendUpdateStatus(status) {
|
function ipcChannelSendUpdateStatus(status) {
|
||||||
if (global.mainWindow) {
|
if (!global.mainWindow) return;
|
||||||
global.mainWindow.webContents.send('check_updates', status);
|
global.mainWindow.webContents.send('check_updates', status);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cache the latest update which has been downloaded as electron offers no api to read it
|
||||||
|
let latestUpdateDownloaded;
|
||||||
autoUpdater.on('update-available', function() {
|
autoUpdater.on('update-available', function() {
|
||||||
ipcChannelSendUpdateStatus(true);
|
ipcChannelSendUpdateStatus(true);
|
||||||
}).on('update-not-available', function() {
|
}).on('update-not-available', function() {
|
||||||
ipcChannelSendUpdateStatus(false);
|
if (latestUpdateDownloaded) {
|
||||||
|
// the only time we will get `update-not-available` if `latestUpdateDownloaded` is already set
|
||||||
|
// is if the user used the Manual Update check and there is no update newer than the one we
|
||||||
|
// have downloaded, so show it to them as the latest again.
|
||||||
|
ipcChannelSendUpdateStatus(true);
|
||||||
|
global.mainWindow.webContents.send('update-downloaded', latestUpdateDownloaded);
|
||||||
|
} else {
|
||||||
|
ipcChannelSendUpdateStatus(false);
|
||||||
|
}
|
||||||
}).on('error', function(error) {
|
}).on('error', function(error) {
|
||||||
ipcChannelSendUpdateStatus(error.message);
|
ipcChannelSendUpdateStatus(error.message);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
autoUpdater.on('update-downloaded', (ev, releaseNotes, releaseName, releaseDate, updateURL) => {
|
||||||
|
if (!global.mainWindow) return;
|
||||||
|
// forward to renderer
|
||||||
|
latestUpdateDownloaded = { releaseNotes, releaseName, releaseDate, updateURL };
|
||||||
|
global.mainWindow.webContents.send('update-downloaded', latestUpdateDownloaded);
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user