Fix auto-updater on mac not working

This commit is contained in:
theolivenbaum
2021-11-10 07:46:25 +01:00
parent 2cc6823604
commit 54c86d9e2f
2 changed files with 36 additions and 30 deletions

View File

@@ -102,22 +102,25 @@ module.exports = (socket, app) => {
});
socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => {
app.removeAllListeners("window-all-closed");
setImmediate(() => {
const windows = electron_1.BrowserWindow.getAllWindows();
if (windows.length) {
windows.forEach(w => {
try {
w.removeAllListeners('close');
w.hide();
w.destroy();
}
catch {
//ignore, probably already destroyed
}
});
}
const windows = electron_1.BrowserWindow.getAllWindows();
if (windows.length) {
windows.forEach(w => {
try {
w.removeAllListeners('close');
w.removeAllListeners('closed');
w.destroy();
}
catch {
//ignore, probably already destroyed
}
});
}
//The call to quitAndInstall needs to happen after the windows
//get a chance to close and release resources, so it must be done on a timeout
setTimeout(() => {
electron_updater_1.autoUpdater.quitAndInstall(isSilent, isForceRunAfter);
});
}, 100);
});
socket.on('autoUpdaterDownloadUpdate', async (guid) => {
const downloadedPath = await electron_updater_1.autoUpdater.downloadUpdate();

View File

@@ -130,22 +130,25 @@ export = (socket: Socket, app: Electron.App) => {
socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => {
app.removeAllListeners("window-all-closed");
setImmediate(() => {
const windows = BrowserWindow.getAllWindows();
if (windows.length) {
windows.forEach(w => {
try {
w.removeAllListeners('close');
w.hide();
w.destroy();
}
catch {
//ignore, probably already destroyed
}
});
}
const windows = BrowserWindow.getAllWindows();
if (windows.length) {
windows.forEach(w => {
try {
w.removeAllListeners('close');
w.removeAllListeners('closed');
w.destroy();
}
catch {
//ignore, probably already destroyed
}
});
}
//The call to quitAndInstall needs to happen after the windows
//get a chance to close and release resources, so it must be done on a timeout
setTimeout(() => {
autoUpdater.quitAndInstall(isSilent, isForceRunAfter);
});
}, 100);
});
socket.on('autoUpdaterDownloadUpdate', async (guid) => {