From 353da78d4b1dccd969bb6c4f5e933446e7e2fda6 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Mon, 17 Apr 2023 16:44:37 -0400 Subject: [PATCH] chore: Switch defaultUpdateChannel to not use Initializable at all Signed-off-by: Sebastian Malton --- .../src/common/__tests__/user-store.test.ts | 3 --- .../default-update-channel.injectable.ts | 6 ++--- .../selected-update-channel.injectable.ts | 4 ++-- .../main/load-storage.injectable.ts | 4 ++-- .../renderer/load-storage.injectable.ts | 4 ++-- .../default-update-channel/init.injectable.ts | 23 ------------------- .../default-update-channel/init.injectable.ts | 23 ------------------- 7 files changed, 9 insertions(+), 58 deletions(-) delete mode 100644 packages/core/src/main/vars/default-update-channel/init.injectable.ts delete mode 100644 packages/core/src/renderer/vars/default-update-channel/init.injectable.ts diff --git a/packages/core/src/common/__tests__/user-store.test.ts b/packages/core/src/common/__tests__/user-store.test.ts index bbf78aea0e..25c4f1eeea 100644 --- a/packages/core/src/common/__tests__/user-store.test.ts +++ b/packages/core/src/common/__tests__/user-store.test.ts @@ -8,7 +8,6 @@ import { defaultThemeId } from "../vars"; import writeFileInjectable from "../fs/write-file.injectable"; import { getDiForUnitTesting } from "../../main/getDiForUnitTesting"; import storeMigrationVersionInjectable from "../vars/store-migration-version.injectable"; -import defaultUpdateChannelInjectable from "../../features/application-update/common/selected-update-channel/default-update-channel.injectable"; import writeJsonSyncInjectable from "../fs/write-json-sync.injectable"; import writeFileSyncInjectable from "../fs/write-file-sync.injectable"; import type { UserPreferencesState } from "../../features/user-preferences/common/state.injectable"; @@ -32,8 +31,6 @@ describe("user store tests", () => { di.override(releaseChannelInjectable, () => "latest"); - await di.inject(defaultUpdateChannelInjectable).init(); - state = di.inject(userPreferencesStateInjectable); resetTheme = di.inject(resetThemeInjectable); }); diff --git a/packages/core/src/features/application-update/common/selected-update-channel/default-update-channel.injectable.ts b/packages/core/src/features/application-update/common/selected-update-channel/default-update-channel.injectable.ts index 11d55c0a68..48047e5ce9 100644 --- a/packages/core/src/features/application-update/common/selected-update-channel/default-update-channel.injectable.ts +++ b/packages/core/src/features/application-update/common/selected-update-channel/default-update-channel.injectable.ts @@ -3,12 +3,12 @@ * Licensed under MIT License. See LICENSE in root directory for more information. */ import { updateChannels } from "../update-channels"; -import { createInitializableState } from "../../../../common/initializable-state/create"; import releaseChannelInjectable from "../../../vars/common/release-channel.injectable"; +import { getInjectable } from "@ogre-tools/injectable"; -const defaultUpdateChannelInjectable = createInitializableState({ +const defaultUpdateChannelInjectable = getInjectable({ id: "default-update-channel", - init: (di) => updateChannels[di.inject(releaseChannelInjectable)], + instantiate: (di) => updateChannels[di.inject(releaseChannelInjectable)], }); export default defaultUpdateChannelInjectable; diff --git a/packages/core/src/features/application-update/common/selected-update-channel/selected-update-channel.injectable.ts b/packages/core/src/features/application-update/common/selected-update-channel/selected-update-channel.injectable.ts index d11778b9bd..7d32cb9b81 100644 --- a/packages/core/src/features/application-update/common/selected-update-channel/selected-update-channel.injectable.ts +++ b/packages/core/src/features/application-update/common/selected-update-channel/selected-update-channel.injectable.ts @@ -22,13 +22,13 @@ const selectedUpdateChannelInjectable = getInjectable({ const state = observable.box(undefined, { deep: false }); return { - value: computed(() => state.get() ?? defaultUpdateChannel.get()), + value: computed(() => state.get() ?? defaultUpdateChannel), setValue: action((channelId) => { const targetUpdateChannel = channelId && updateChannels[channelId] ? updateChannels[channelId] - : defaultUpdateChannel.get(); + : defaultUpdateChannel; state.set(targetUpdateChannel); }), diff --git a/packages/core/src/features/user-preferences/main/load-storage.injectable.ts b/packages/core/src/features/user-preferences/main/load-storage.injectable.ts index dac1c2aebb..2a68d9c4a1 100644 --- a/packages/core/src/features/user-preferences/main/load-storage.injectable.ts +++ b/packages/core/src/features/user-preferences/main/load-storage.injectable.ts @@ -4,9 +4,9 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application"; -import initDefaultUpdateChannelInjectable from "../../../main/vars/default-update-channel/init.injectable"; import userPreferencesPersistentStorageInjectable from "../common/storage.injectable"; import userPreferencesStorageFileNameMigrationInjectable from "./file-name-migration.injectable"; +import { buildVersionInitializationInjectable } from "../../vars/build-version/main/init.injectable"; const loadUserPreferencesStorageInjectable = getInjectable({ id: "load-user-preferences-storage", @@ -18,7 +18,7 @@ const loadUserPreferencesStorageInjectable = getInjectable({ await userStoreFileNameMigration(); storage.loadAndStartSyncing(); }, - runAfter: initDefaultUpdateChannelInjectable, + runAfter: buildVersionInitializationInjectable, }), injectionToken: beforeApplicationIsLoadingInjectionToken, }); diff --git a/packages/core/src/features/user-preferences/renderer/load-storage.injectable.ts b/packages/core/src/features/user-preferences/renderer/load-storage.injectable.ts index 43e10c1707..1f3c3a0e6f 100644 --- a/packages/core/src/features/user-preferences/renderer/load-storage.injectable.ts +++ b/packages/core/src/features/user-preferences/renderer/load-storage.injectable.ts @@ -4,7 +4,7 @@ */ import { getInjectable } from "@ogre-tools/injectable"; import { beforeFrameStartsSecondInjectionToken } from "../../../renderer/before-frame-starts/tokens"; -import initDefaultUpdateChannelInjectable from "../../../renderer/vars/default-update-channel/init.injectable"; +import { buildVersionInitializationInjectable } from "../../vars/build-version/renderer/init.injectable"; import userPreferencesPersistentStorageInjectable from "../common/storage.injectable"; const loadUserPreferencesStorageInjectable = getInjectable({ @@ -15,7 +15,7 @@ const loadUserPreferencesStorageInjectable = getInjectable({ return storage.loadAndStartSyncing(); }, - runAfter: initDefaultUpdateChannelInjectable, + runAfter: buildVersionInitializationInjectable, }), injectionToken: beforeFrameStartsSecondInjectionToken, }); diff --git a/packages/core/src/main/vars/default-update-channel/init.injectable.ts b/packages/core/src/main/vars/default-update-channel/init.injectable.ts deleted file mode 100644 index 7b18a4e61f..0000000000 --- a/packages/core/src/main/vars/default-update-channel/init.injectable.ts +++ /dev/null @@ -1,23 +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 { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application"; -import defaultUpdateChannelInjectable from "../../../features/application-update/common/selected-update-channel/default-update-channel.injectable"; -import { buildVersionInitializationInjectable } from "../../../features/vars/build-version/main/init.injectable"; - -const initDefaultUpdateChannelInjectable = getInjectable({ - id: "init-default-update-channel", - instantiate: (di) => ({ - run: async () => { - const defaultUpdateChannel = di.inject(defaultUpdateChannelInjectable); - - await defaultUpdateChannel.init(); - }, - runAfter: buildVersionInitializationInjectable, - }), - injectionToken: beforeApplicationIsLoadingInjectionToken, -}); - -export default initDefaultUpdateChannelInjectable; diff --git a/packages/core/src/renderer/vars/default-update-channel/init.injectable.ts b/packages/core/src/renderer/vars/default-update-channel/init.injectable.ts deleted file mode 100644 index e5a79bbbf0..0000000000 --- a/packages/core/src/renderer/vars/default-update-channel/init.injectable.ts +++ /dev/null @@ -1,23 +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 { beforeFrameStartsSecondInjectionToken } from "../../before-frame-starts/tokens"; -import defaultUpdateChannelInjectable from "../../../features/application-update/common/selected-update-channel/default-update-channel.injectable"; -import { buildVersionInitializationInjectable } from "../../../features/vars/build-version/renderer/init.injectable"; - -const initDefaultUpdateChannelInjectable = getInjectable({ - id: "init-default-update-channel", - instantiate: (di) => ({ - run: async () => { - const defaultUpdateChannel = di.inject(defaultUpdateChannelInjectable); - - await defaultUpdateChannel.init(); - }, - runAfter: buildVersionInitializationInjectable, - }), - injectionToken: beforeFrameStartsSecondInjectionToken, -}); - -export default initDefaultUpdateChannelInjectable;