From 5477bd7f366cac0493c9315a9bffa263ec9dfeab Mon Sep 17 00:00:00 2001 From: rafael-aero Date: Tue, 2 Nov 2021 15:39:57 +0100 Subject: [PATCH] Add setImmediate to see if this fixes the macOS update bug --- ElectronNET.Host/api/autoUpdater.js | 30 +++++++++++++++-------------- ElectronNET.Host/api/autoUpdater.ts | 30 +++++++++++++++-------------- 2 files changed, 32 insertions(+), 28 deletions(-) diff --git a/ElectronNET.Host/api/autoUpdater.js b/ElectronNET.Host/api/autoUpdater.js index 281b4aa..63e4c07 100644 --- a/ElectronNET.Host/api/autoUpdater.js +++ b/ElectronNET.Host/api/autoUpdater.js @@ -102,20 +102,22 @@ module.exports = (socket, app) => { }); socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => { app.removeAllListeners("window-all-closed"); - 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 - } - }); - } - electron_updater_1.autoUpdater.quitAndInstall(isSilent, isForceRunAfter); + 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 + } + }); + } + electron_updater_1.autoUpdater.quitAndInstall(isSilent, isForceRunAfter); + }); }); socket.on('autoUpdaterDownloadUpdate', async (guid) => { const downloadedPath = await electron_updater_1.autoUpdater.downloadUpdate(); diff --git a/ElectronNET.Host/api/autoUpdater.ts b/ElectronNET.Host/api/autoUpdater.ts index 533043a..9451844 100644 --- a/ElectronNET.Host/api/autoUpdater.ts +++ b/ElectronNET.Host/api/autoUpdater.ts @@ -130,20 +130,22 @@ export = (socket: Socket, app: Electron.App) => { socket.on('autoUpdaterQuitAndInstall', async (isSilent, isForceRunAfter) => { app.removeAllListeners("window-all-closed"); - const windows = BrowserWindow.getAllWindows(); - if (windows.length) { - windows.forEach(w => { - try { - w.removeAllListeners('close'); - w.hide(); - w.destroy(); - } - catch { - //ignore, probably already destroyed - } - }); - } - autoUpdater.quitAndInstall(isSilent, isForceRunAfter); + setImmediate(() => { + const windows = BrowserWindow.getAllWindows(); + if (windows.length) { + windows.forEach(w => { + try { + w.removeAllListeners('close'); + w.hide(); + w.destroy(); + } + catch { + //ignore, probably already destroyed + } + }); + } + autoUpdater.quitAndInstall(isSilent, isForceRunAfter); + }); }); socket.on('autoUpdaterDownloadUpdate', async (guid) => {