From b9ea16c51cccb2168aa5ce02c4db44417bb66f8b Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Wed, 26 Mar 2025 15:39:18 +0100 Subject: [PATCH 1/3] clear extra log --- desktop/main.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/desktop/main.ts b/desktop/main.ts index 4191d609efa33..9adc84b8a1668 100644 --- a/desktop/main.ts +++ b/desktop/main.ts @@ -19,8 +19,6 @@ import type {CreateDownloadQueueModule, DownloadItem} from './createDownloadQueu import serve from './electron-serve'; import ELECTRON_EVENTS from './ELECTRON_EVENTS'; -console.log('[dev] main'); - const createDownloadQueue = require('./createDownloadQueue').default; const port = process.env.PORT ?? 8082; From f7d28cc540f46b6da6f43df2fc93eb4cc8c5a93e Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Wed, 26 Mar 2025 15:39:37 +0100 Subject: [PATCH 2/3] integrate verifyAndInstallLatestVersion --- desktop/main.ts | 57 ++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/desktop/main.ts b/desktop/main.ts index 9adc84b8a1668..75bee3b2a42ed 100644 --- a/desktop/main.ts +++ b/desktop/main.ts @@ -146,6 +146,33 @@ const quitAndInstallWithUpdate = () => { autoUpdater.quitAndInstall(); }; +const verifyAndInstallLatestVersion = (): void => { + console.log('[dev] verifyAndInstallLatestVersion'); + + autoUpdater + .checkForUpdates() + .then((result) => { + console.log('[dev] verifyAndInstallLatestVersion: result', result); + console.log('[dev] verifyAndInstallLatestVersion: downloadedVersion', downloadedVersion); + + if (result?.updateInfo.version === downloadedVersion) { + console.log('[dev] verifyAndInstallLatestVersion: if - versions match, installing'); + return quitAndInstallWithUpdate(); + } + + console.log('[dev] verifyAndInstallLatestVersion: else - downloading new update'); + + return autoUpdater.downloadUpdate().then(() => { + console.log('[dev] verifyAndInstallLatestVersion: download complete, installing'); + return quitAndInstallWithUpdate(); + }); + }) + .catch((error) => { + console.log('[dev] verifyAndInstallLatestVersion: error', error); + log.error('Error during update check or download:', error); + }); +}; + /** Menu Item callback to trigger an update check */ const manuallyCheckForUpdates = (menuItem?: MenuItem, browserWindow?: BaseWindow) => { if (menuItem) { @@ -242,33 +269,14 @@ const electronUpdater = (browserWindow: BrowserWindow): PlatformSpecificUpdater browserWindow.webContents.send(ELECTRON_EVENTS.UPDATE_DOWNLOADED, info.version); } else { console.log('[dev] else'); - - autoUpdater - .checkForUpdates() - .then((result) => { - console.log('[dev] result', result); - if (result?.updateInfo.version === downloadedVersion) { - console.log('[dev] if - versions match, installing'); - quitAndInstallWithUpdate(); - } else { - console.log('[dev] else - downloading new update'); - return autoUpdater.downloadUpdate().then(() => { - console.log('[dev] download complete, installing'); - quitAndInstallWithUpdate(); - }); - } - }) - .catch((error) => { - console.log('[dev] error', error); - log.error('Error during update check or download:', error); - }); + verifyAndInstallLatestVersion(); } }); console.log('[dev] ipcMain.on(ELECTRON_EVENTS.START_UPDATE, quitAndInstallWithUpdate)'); ipcMain.on(ELECTRON_EVENTS.START_UPDATE, () => { console.log('[dev] ELECTRON_EVENTS.START_UPDATE'); - quitAndInstallWithUpdate(); + verifyAndInstallLatestVersion(); }); autoUpdater.checkForUpdates().then((result) => { console.log('[dev] update result 1: ', result); @@ -416,7 +424,12 @@ const mainWindow = (): Promise => { label: translate(preferredLocale, `desktopApplicationMenu.mainMenu`), submenu: [ {id: 'about', role: 'about'}, - {id: 'update', label: translate(preferredLocale, `desktopApplicationMenu.update`), click: quitAndInstallWithUpdate, visible: false}, + { + id: 'update', + label: translate(preferredLocale, `desktopApplicationMenu.update`), + click: verifyAndInstallLatestVersion, + visible: false, + }, {id: 'checkForUpdates', label: translate(preferredLocale, `desktopApplicationMenu.checkForUpdates`), click: manuallyCheckForUpdates}, { id: 'viewShortcuts', From 6ccecde0d71a9f21bef151511c0173ef3b1d9486 Mon Sep 17 00:00:00 2001 From: Mykhailo Kravchenko Date: Wed, 26 Mar 2025 18:36:31 +0100 Subject: [PATCH 3/3] Revert "clear extra log" This reverts commit b9ea16c51cccb2168aa5ce02c4db44417bb66f8b. --- desktop/main.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/desktop/main.ts b/desktop/main.ts index 75bee3b2a42ed..f6e83dc524594 100644 --- a/desktop/main.ts +++ b/desktop/main.ts @@ -19,6 +19,8 @@ import type {CreateDownloadQueueModule, DownloadItem} from './createDownloadQueu import serve from './electron-serve'; import ELECTRON_EVENTS from './ELECTRON_EVENTS'; +console.log('[dev] main'); + const createDownloadQueue = require('./createDownloadQueue').default; const port = process.env.PORT ?? 8082;