diff --git a/src/main/app-updater.ts b/src/main/app-updater.ts index 5d2147923c..9a5d2f0212 100644 --- a/src/main/app-updater.ts +++ b/src/main/app-updater.ts @@ -42,10 +42,14 @@ autoUpdater.logger = { debug: message => logger.debug(`[AUTO-UPDATE]: electron-updater: %s`, message), }; +interface Dependencies { + isAutoUpdateEnabled: () => boolean; +} + /** * starts the automatic update checking */ -export const startUpdateChecking = (isAutoUpdateEnabled : () => boolean) => once(function (interval = 1000 * 60 * 60 * 24): void { +export const startUpdateChecking = ({ isAutoUpdateEnabled } : Dependencies) => once(function (interval = 1000 * 60 * 60 * 24): void { if (!isAutoUpdateEnabled() || isTestEnv) { return; } diff --git a/src/main/electron-app/runnables/setup-update-checking.injectable.ts b/src/main/electron-app/runnables/setup-update-checking.injectable.ts index 9c69328541..918e985265 100644 --- a/src/main/electron-app/runnables/setup-update-checking.injectable.ts +++ b/src/main/electron-app/runnables/setup-update-checking.injectable.ts @@ -4,24 +4,21 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { afterRootFrameIsReadyInjectionToken } from "../../start-main-application/runnable-tokens/after-root-frame-is-ready-injection-token"; -import { startUpdateChecking } from "../../app-updater"; -import isAutoUpdateEnabledInjectable from "../../is-auto-update-enabled.injectable"; +import startUpdateCheckingInjectable from "../../start-update-checking.injectable"; const setupUpdateCheckingInjectable = getInjectable({ id: "setup-update-checking", instantiate: (di) => { - const isAutoUpdateEnabled = di.inject(isAutoUpdateEnabledInjectable); + const startUpdateChecking = di.inject(startUpdateCheckingInjectable); return { run: () => { - startUpdateChecking(isAutoUpdateEnabled)(); + startUpdateChecking(); }, }; }, - causesSideEffects: true, - injectionToken: afterRootFrameIsReadyInjectionToken, }); diff --git a/src/main/start-update-checking.injectable.ts b/src/main/start-update-checking.injectable.ts new file mode 100644 index 0000000000..4571e70df4 --- /dev/null +++ b/src/main/start-update-checking.injectable.ts @@ -0,0 +1,19 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { getInjectable } from "@ogre-tools/injectable"; +import { startUpdateChecking } from "./app-updater"; +import isAutoUpdateEnabledInjectable from "./is-auto-update-enabled.injectable"; + +const startUpdateCheckingInjectable = getInjectable({ + id: "start-update-checking", + + instantiate: (di) => startUpdateChecking({ + isAutoUpdateEnabled: di.inject(isAutoUpdateEnabledInjectable), + }), + + causesSideEffects: true, +}); + +export default startUpdateCheckingInjectable;