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 SavolainenandMikko Aspiala committed 2022-05-11 08:28:12 +03:00
1 parent 82336d7a12
commit 1810a330cf
2 files changed
+7 -3

No files matched your search

@@ -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,
});
},
};
@@ -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();