1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

chore: Switch defaultUpdateChannel to not use Initializable at all

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2023-04-17 16:44:37 -04:00
parent 53920a7046
commit 353da78d4b
7 changed files with 9 additions and 58 deletions

View File

@ -8,7 +8,6 @@ import { defaultThemeId } from "../vars";
import writeFileInjectable from "../fs/write-file.injectable"; import writeFileInjectable from "../fs/write-file.injectable";
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting"; import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
import storeMigrationVersionInjectable from "../vars/store-migration-version.injectable"; 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 writeJsonSyncInjectable from "../fs/write-json-sync.injectable";
import writeFileSyncInjectable from "../fs/write-file-sync.injectable"; import writeFileSyncInjectable from "../fs/write-file-sync.injectable";
import type { UserPreferencesState } from "../../features/user-preferences/common/state.injectable"; import type { UserPreferencesState } from "../../features/user-preferences/common/state.injectable";
@ -32,8 +31,6 @@ describe("user store tests", () => {
di.override(releaseChannelInjectable, () => "latest"); di.override(releaseChannelInjectable, () => "latest");
await di.inject(defaultUpdateChannelInjectable).init();
state = di.inject(userPreferencesStateInjectable); state = di.inject(userPreferencesStateInjectable);
resetTheme = di.inject(resetThemeInjectable); resetTheme = di.inject(resetThemeInjectable);
}); });

View File

@ -3,12 +3,12 @@
* Licensed under MIT License. See LICENSE in root directory for more information. * Licensed under MIT License. See LICENSE in root directory for more information.
*/ */
import { updateChannels } from "../update-channels"; import { updateChannels } from "../update-channels";
import { createInitializableState } from "../../../../common/initializable-state/create";
import releaseChannelInjectable from "../../../vars/common/release-channel.injectable"; import releaseChannelInjectable from "../../../vars/common/release-channel.injectable";
import { getInjectable } from "@ogre-tools/injectable";
const defaultUpdateChannelInjectable = createInitializableState({ const defaultUpdateChannelInjectable = getInjectable({
id: "default-update-channel", id: "default-update-channel",
init: (di) => updateChannels[di.inject(releaseChannelInjectable)], instantiate: (di) => updateChannels[di.inject(releaseChannelInjectable)],
}); });
export default defaultUpdateChannelInjectable; export default defaultUpdateChannelInjectable;

View File

@ -22,13 +22,13 @@ const selectedUpdateChannelInjectable = getInjectable({
const state = observable.box<UpdateChannel>(undefined, { deep: false }); const state = observable.box<UpdateChannel>(undefined, { deep: false });
return { return {
value: computed(() => state.get() ?? defaultUpdateChannel.get()), value: computed(() => state.get() ?? defaultUpdateChannel),
setValue: action((channelId) => { setValue: action((channelId) => {
const targetUpdateChannel = const targetUpdateChannel =
channelId && updateChannels[channelId] channelId && updateChannels[channelId]
? updateChannels[channelId] ? updateChannels[channelId]
: defaultUpdateChannel.get(); : defaultUpdateChannel;
state.set(targetUpdateChannel); state.set(targetUpdateChannel);
}), }),

View File

@ -4,9 +4,9 @@
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application"; import { beforeApplicationIsLoadingInjectionToken } from "@k8slens/application";
import initDefaultUpdateChannelInjectable from "../../../main/vars/default-update-channel/init.injectable";
import userPreferencesPersistentStorageInjectable from "../common/storage.injectable"; import userPreferencesPersistentStorageInjectable from "../common/storage.injectable";
import userPreferencesStorageFileNameMigrationInjectable from "./file-name-migration.injectable"; import userPreferencesStorageFileNameMigrationInjectable from "./file-name-migration.injectable";
import { buildVersionInitializationInjectable } from "../../vars/build-version/main/init.injectable";
const loadUserPreferencesStorageInjectable = getInjectable({ const loadUserPreferencesStorageInjectable = getInjectable({
id: "load-user-preferences-storage", id: "load-user-preferences-storage",
@ -18,7 +18,7 @@ const loadUserPreferencesStorageInjectable = getInjectable({
await userStoreFileNameMigration(); await userStoreFileNameMigration();
storage.loadAndStartSyncing(); storage.loadAndStartSyncing();
}, },
runAfter: initDefaultUpdateChannelInjectable, runAfter: buildVersionInitializationInjectable,
}), }),
injectionToken: beforeApplicationIsLoadingInjectionToken, injectionToken: beforeApplicationIsLoadingInjectionToken,
}); });

View File

@ -4,7 +4,7 @@
*/ */
import { getInjectable } from "@ogre-tools/injectable"; import { getInjectable } from "@ogre-tools/injectable";
import { beforeFrameStartsSecondInjectionToken } from "../../../renderer/before-frame-starts/tokens"; 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"; import userPreferencesPersistentStorageInjectable from "../common/storage.injectable";
const loadUserPreferencesStorageInjectable = getInjectable({ const loadUserPreferencesStorageInjectable = getInjectable({
@ -15,7 +15,7 @@ const loadUserPreferencesStorageInjectable = getInjectable({
return storage.loadAndStartSyncing(); return storage.loadAndStartSyncing();
}, },
runAfter: initDefaultUpdateChannelInjectable, runAfter: buildVersionInitializationInjectable,
}), }),
injectionToken: beforeFrameStartsSecondInjectionToken, injectionToken: beforeFrameStartsSecondInjectionToken,
}); });

View File

@ -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;

View File

@ -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;