mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Convert runManyFor to use composite Signed-off-by: Sebastian Malton <sebastian@malton.name> * Convert runManySyncFor to use composite and to enfore sync-ness Signed-off-by: Sebastian Malton <sebastian@malton.name> * Remove dead code Signed-off-by: Sebastian Malton <sebastian@malton.name> * Convert getStartableStoppable to be always sync as it is never used in an async fashion Signed-off-by: Sebastian Malton <sebastian@malton.name> * Convert all sync runnables to comply with new checks for sync-ness Signed-off-by: Sebastian Malton <sebastian@malton.name> Signed-off-by: Sebastian Malton <sebastian@malton.name>
34 lines
1.2 KiB
TypeScript
34 lines
1.2 KiB
TypeScript
/**
|
|
* 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 { getStartableStoppable } from "../../../common/utils/get-startable-stoppable";
|
|
import operatingSystemThemeStateInjectable from "../../theme/operating-system-theme-state.injectable";
|
|
import nativeThemeInjectable from "./native-theme.injectable";
|
|
import getElectronThemeInjectable from "./get-electron-theme.injectable";
|
|
|
|
const syncThemeFromOperatingSystemInjectable = getInjectable({
|
|
id: "sync-theme-from-operating-system",
|
|
|
|
instantiate: (di) => {
|
|
const currentThemeState = di.inject(operatingSystemThemeStateInjectable);
|
|
const nativeTheme = di.inject(nativeThemeInjectable);
|
|
const getElectronTheme = di.inject(getElectronThemeInjectable);
|
|
|
|
return getStartableStoppable("sync-theme-from-operating-system", () => {
|
|
const updateThemeState = () => {
|
|
currentThemeState.set(getElectronTheme());
|
|
};
|
|
|
|
nativeTheme.on("updated", updateThemeState);
|
|
|
|
return () => {
|
|
nativeTheme.off("updated", updateThemeState);
|
|
};
|
|
});
|
|
},
|
|
});
|
|
|
|
export default syncThemeFromOperatingSystemInjectable;
|