From a52b206dfba2a4f17154bcec61156ce7f80acaf8 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Fri, 9 Aug 2024 11:45:08 +0100 Subject: [PATCH] Chore: Temporarily disable new auto-update code --- packages/app-desktop/ElectronAppWrapper.ts | 14 ++++++++------ packages/app-desktop/app.ts | 17 +++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/packages/app-desktop/ElectronAppWrapper.ts b/packages/app-desktop/ElectronAppWrapper.ts index aae7e5cbb..8d6d01f5f 100644 --- a/packages/app-desktop/ElectronAppWrapper.ts +++ b/packages/app-desktop/ElectronAppWrapper.ts @@ -1,6 +1,6 @@ import Logger, { LoggerWrapper } from '@joplin/utils/Logger'; import { PluginMessage } from './services/plugins/PluginRunner'; -import AutoUpdaterService from './services/autoUpdater/AutoUpdaterService'; +// import AutoUpdaterService from './services/autoUpdater/AutoUpdaterService'; import shim from '@joplin/lib/shim'; import { isCallbackUrl } from '@joplin/lib/callbackUrlUtils'; @@ -42,7 +42,7 @@ export default class ElectronAppWrapper { private rendererProcessQuitReply_: RendererProcessQuitReply = null; private pluginWindows_: PluginWindows = {}; private initialCallbackUrl_: string = null; - private updaterService_: AutoUpdaterService = null; + // private updaterService_: AutoUpdaterService = null; private customProtocolHandler_: CustomProtocolHandler = null; // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied @@ -476,10 +476,12 @@ export default class ElectronAppWrapper { this.createWindow(); - if (!shim.isLinux()) { - this.updaterService_ = new AutoUpdaterService(); - this.updaterService_.startPeriodicUpdateCheck(); - } + // TODO: Disabled for now - needs to be behind a feature flag + + // if (!shim.isLinux()) { + // this.updaterService_ = new AutoUpdaterService(); + // this.updaterService_.startPeriodicUpdateCheck(); + // } this.electronApp_.on('before-quit', () => { this.willQuitApp_ = true; diff --git a/packages/app-desktop/app.ts b/packages/app-desktop/app.ts index 99101249e..e10eea5bc 100644 --- a/packages/app-desktop/app.ts +++ b/packages/app-desktop/app.ts @@ -59,6 +59,7 @@ const globalCommands = appCommands.concat(libCommands); import editorCommandDeclarations from './gui/NoteEditor/editorCommandDeclarations'; import PerFolderSortOrderService from './services/sortOrder/PerFolderSortOrderService'; import ShareService from '@joplin/lib/services/share/ShareService'; +import checkForUpdates from './checkForUpdates'; import { AppState } from './app.reducer'; import syncDebugLog from '@joplin/lib/services/synchronizer/syncDebugLog'; import eventManager, { EventName } from '@joplin/lib/eventManager'; @@ -565,6 +566,22 @@ class Application extends BaseApplication { value: Setting.value('flagOpenDevTools'), }); + // Note: Auto-update is a misnomer in the code. + // The code below only checks, if a new version is available. + // We only allow Windows and macOS users to automatically check for updates + if (shim.isWindows() || shim.isMac()) { + const runAutoUpdateCheck = () => { + if (Setting.value('autoUpdateEnabled')) { + void checkForUpdates(true, bridge().window(), { includePreReleases: Setting.value('autoUpdate.includePreReleases') }); + } + }; + + // Initial check on startup + shim.setTimeout(() => { runAutoUpdateCheck(); }, 5000); + // Then every x hours + shim.setInterval(() => { runAutoUpdateCheck(); }, 12 * 60 * 60 * 1000); + } + initializeUserFetcher(); shim.setInterval(() => { void userFetcher(); }, 1000 * 60 * 60);