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

Switch to using dependency over using explicit side-effect

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-05-04 14:15:56 +03:00
parent 82336d7a12
commit 1810a330cf
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
2 changed files with 7 additions and 3 deletions

View File

@ -12,6 +12,7 @@ import getAbsolutePathInjectable from "../../../../common/path/get-absolute-path
import catalogEntityRegistryInjectable from "../../../catalog/catalog-entity-registry.injectable";
import clusterStoreInjectable from "../../../../common/cluster-store/cluster-store.injectable";
import { whenApplicationIsLoadingInjectionToken } from "../../../start-main-application/runnable-tokens/when-application-is-loading-injection-token";
import currentOperatingSystemThemeInjectable from "../../../theme/current-operating-system-theme.injectable";
const setupIpcMainHandlersInjectable = getInjectable({
id: "setup-ipc-main-handlers",
@ -28,6 +29,7 @@ const setupIpcMainHandlersInjectable = getInjectable({
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
const clusterStore = di.inject(clusterStoreInjectable);
const currentOperatingSystemTheme = di.inject(currentOperatingSystemThemeInjectable);
return {
run: () => {
@ -40,6 +42,7 @@ const setupIpcMainHandlersInjectable = getInjectable({
clusterManager,
catalogEntityRegistry,
clusterStore,
currentOperatingSystemTheme,
});
},
};

View File

@ -23,7 +23,7 @@ import { handleWindowAction, onLocationChange } from "../../../ipc/window";
import { openFilePickingDialogChannel } from "../../../../common/ipc/dialog";
import { showOpenDialog } from "../../../ipc/dialog";
import { getNativeThemeChannel } from "../../../../common/ipc/native-theme";
import { getNativeColorTheme } from "../../../native-theme";
import type { Theme } from "../../../theme/current-operating-system-theme-state.injectable";
interface Dependencies {
directoryForLensLocalStorage: string;
@ -32,9 +32,10 @@ interface Dependencies {
clusterManager: ClusterManager;
catalogEntityRegistry: CatalogEntityRegistry;
clusterStore: ClusterStore;
currentOperatingSystemTheme: IComputedValue<Theme>;
}
export const setupIpcMainHandlers = ({ applicationMenuItems, directoryForLensLocalStorage, getAbsolutePath, clusterManager, catalogEntityRegistry, clusterStore }: Dependencies) => {
export const setupIpcMainHandlers = ({ applicationMenuItems, directoryForLensLocalStorage, getAbsolutePath, clusterManager, catalogEntityRegistry, clusterStore, currentOperatingSystemTheme }: Dependencies) => {
ipcMainHandle(clusterActivateHandler, (event, clusterId: ClusterId, force = false) => {
return ClusterStore.getInstance()
.getById(clusterId)
@ -166,7 +167,7 @@ export const setupIpcMainHandlers = ({ applicationMenuItems, directoryForLensLoc
});
ipcMainHandle(getNativeThemeChannel, () => {
return getNativeColorTheme();
return currentOperatingSystemTheme.get();
});
clusterStore.provideInitialFromMain();