From 5d76dd4fc2c254c43a57a2888fe04b83fa79fc47 Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Wed, 29 Jun 2022 15:22:08 +0300 Subject: [PATCH] Stop trying to restart catalog sync and updating of application when reloading window (#5735) --- .../start-checking-for-updates.injectable.ts | 2 +- .../start-catalog-sync.injectable.ts | 4 +- src/main/getDiForUnitTesting.ts | 2 - ...or-after-root-frame-is-ready.injectable.ts | 37 ------------------- 4 files changed, 4 insertions(+), 41 deletions(-) delete mode 100644 src/main/start-main-application/runnables/setup-runnables-for-after-root-frame-is-ready.injectable.ts diff --git a/src/main/application-update/periodical-check-for-updates/start-checking-for-updates.injectable.ts b/src/main/application-update/periodical-check-for-updates/start-checking-for-updates.injectable.ts index 9a9b9cf206..4c80e8178e 100644 --- a/src/main/application-update/periodical-check-for-updates/start-checking-for-updates.injectable.ts +++ b/src/main/application-update/periodical-check-for-updates/start-checking-for-updates.injectable.ts @@ -16,7 +16,7 @@ const startCheckingForUpdatesInjectable = getInjectable({ return { run: async () => { - if (updatingIsEnabled) { + if (updatingIsEnabled && !periodicalCheckForUpdates.started) { await periodicalCheckForUpdates.start(); } }, diff --git a/src/main/catalog-sync-to-renderer/start-catalog-sync.injectable.ts b/src/main/catalog-sync-to-renderer/start-catalog-sync.injectable.ts index 71afc4d895..3dfd9ee2ae 100644 --- a/src/main/catalog-sync-to-renderer/start-catalog-sync.injectable.ts +++ b/src/main/catalog-sync-to-renderer/start-catalog-sync.injectable.ts @@ -14,7 +14,9 @@ const startCatalogSyncInjectable = getInjectable({ return { run: async () => { - await catalogSyncToRenderer.start(); + if (!catalogSyncToRenderer.started) { + await catalogSyncToRenderer.start(); + } }, }; }, diff --git a/src/main/getDiForUnitTesting.ts b/src/main/getDiForUnitTesting.ts index 36713d852d..c09142d83d 100644 --- a/src/main/getDiForUnitTesting.ts +++ b/src/main/getDiForUnitTesting.ts @@ -37,7 +37,6 @@ import lensResourcesDirInjectable from "../common/vars/lens-resources-dir.inject import environmentVariablesInjectable from "../common/utils/environment-variables.injectable"; import setupIpcMainHandlersInjectable from "./electron-app/runnables/setup-ipc-main-handlers/setup-ipc-main-handlers.injectable"; import setupLensProxyInjectable from "./start-main-application/runnables/setup-lens-proxy.injectable"; -import setupRunnablesForAfterRootFrameIsReadyInjectable from "./start-main-application/runnables/setup-runnables-for-after-root-frame-is-ready.injectable"; import setupSentryInjectable from "./start-main-application/runnables/setup-sentry.injectable"; import setupShellInjectable from "./start-main-application/runnables/setup-shell.injectable"; import setupSyncingOfWeblinksInjectable from "./start-main-application/runnables/setup-syncing-of-weblinks.injectable"; @@ -212,7 +211,6 @@ const overrideRunnablesHavingSideEffects = (di: DiContainer) => { initializeExtensionsInjectable, setupIpcMainHandlersInjectable, setupLensProxyInjectable, - setupRunnablesForAfterRootFrameIsReadyInjectable, setupSentryInjectable, setupShellInjectable, setupSyncingOfWeblinksInjectable, diff --git a/src/main/start-main-application/runnables/setup-runnables-for-after-root-frame-is-ready.injectable.ts b/src/main/start-main-application/runnables/setup-runnables-for-after-root-frame-is-ready.injectable.ts deleted file mode 100644 index 82c323c501..0000000000 --- a/src/main/start-main-application/runnables/setup-runnables-for-after-root-frame-is-ready.injectable.ts +++ /dev/null @@ -1,37 +0,0 @@ -/** - * 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 { ipcMainOn } from "../../../common/ipc"; -import { IpcRendererNavigationEvents } from "../../../renderer/navigation/events"; -import { afterRootFrameIsReadyInjectionToken } from "../runnable-tokens/after-root-frame-is-ready-injection-token"; -import { runManyFor } from "../../../common/runnable/run-many-for"; -import { onLoadOfApplicationInjectionToken } from "../runnable-tokens/on-load-of-application-injection-token"; - -const setupRunnablesForAfterRootFrameIsReadyInjectable = getInjectable({ - id: "setup-runnables-for-after-root-frame-is-ready", - - instantiate: (di) => { - const runMany = runManyFor(di); - - const runRunnablesAfterRootFrameIsReady = runMany( - afterRootFrameIsReadyInjectionToken, - ); - - return { - run: () => { - ipcMainOn(IpcRendererNavigationEvents.LOADED, async () => { - await runRunnablesAfterRootFrameIsReady(); - }); - }, - }; - }, - - // Direct usage of IPC - causesSideEffects: true, - - injectionToken: onLoadOfApplicationInjectionToken, -}); - -export default setupRunnablesForAfterRootFrameIsReadyInjectable;