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:
parent
82336d7a12
commit
1810a330cf
@ -12,6 +12,7 @@ import getAbsolutePathInjectable from "../../../../common/path/get-absolute-path
|
|||||||
import catalogEntityRegistryInjectable from "../../../catalog/catalog-entity-registry.injectable";
|
import catalogEntityRegistryInjectable from "../../../catalog/catalog-entity-registry.injectable";
|
||||||
import clusterStoreInjectable from "../../../../common/cluster-store/cluster-store.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 { 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({
|
const setupIpcMainHandlersInjectable = getInjectable({
|
||||||
id: "setup-ipc-main-handlers",
|
id: "setup-ipc-main-handlers",
|
||||||
@ -28,6 +29,7 @@ const setupIpcMainHandlersInjectable = getInjectable({
|
|||||||
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
|
const getAbsolutePath = di.inject(getAbsolutePathInjectable);
|
||||||
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
|
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
|
||||||
const clusterStore = di.inject(clusterStoreInjectable);
|
const clusterStore = di.inject(clusterStoreInjectable);
|
||||||
|
const currentOperatingSystemTheme = di.inject(currentOperatingSystemThemeInjectable);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
run: () => {
|
run: () => {
|
||||||
@ -40,6 +42,7 @@ const setupIpcMainHandlersInjectable = getInjectable({
|
|||||||
clusterManager,
|
clusterManager,
|
||||||
catalogEntityRegistry,
|
catalogEntityRegistry,
|
||||||
clusterStore,
|
clusterStore,
|
||||||
|
currentOperatingSystemTheme,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -23,7 +23,7 @@ import { handleWindowAction, onLocationChange } from "../../../ipc/window";
|
|||||||
import { openFilePickingDialogChannel } from "../../../../common/ipc/dialog";
|
import { openFilePickingDialogChannel } from "../../../../common/ipc/dialog";
|
||||||
import { showOpenDialog } from "../../../ipc/dialog";
|
import { showOpenDialog } from "../../../ipc/dialog";
|
||||||
import { getNativeThemeChannel } from "../../../../common/ipc/native-theme";
|
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 {
|
interface Dependencies {
|
||||||
directoryForLensLocalStorage: string;
|
directoryForLensLocalStorage: string;
|
||||||
@ -32,9 +32,10 @@ interface Dependencies {
|
|||||||
clusterManager: ClusterManager;
|
clusterManager: ClusterManager;
|
||||||
catalogEntityRegistry: CatalogEntityRegistry;
|
catalogEntityRegistry: CatalogEntityRegistry;
|
||||||
clusterStore: ClusterStore;
|
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) => {
|
ipcMainHandle(clusterActivateHandler, (event, clusterId: ClusterId, force = false) => {
|
||||||
return ClusterStore.getInstance()
|
return ClusterStore.getInstance()
|
||||||
.getById(clusterId)
|
.getById(clusterId)
|
||||||
@ -166,7 +167,7 @@ export const setupIpcMainHandlers = ({ applicationMenuItems, directoryForLensLoc
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMainHandle(getNativeThemeChannel, () => {
|
ipcMainHandle(getNativeThemeChannel, () => {
|
||||||
return getNativeColorTheme();
|
return currentOperatingSystemTheme.get();
|
||||||
});
|
});
|
||||||
|
|
||||||
clusterStore.provideInitialFromMain();
|
clusterStore.provideInitialFromMain();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user