mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Remove use of global shared Electron.App
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
8d55a3a08d
commit
906172bc29
@ -3,8 +3,7 @@
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { app } from "electron";
|
||||
import { action, observable, reaction, makeObservable, isObservableArray, isObservableSet, isObservableMap } from "mobx";
|
||||
import { action, observable, makeObservable, isObservableArray, isObservableSet, isObservableMap } from "mobx";
|
||||
import type { BaseStoreDependencies } from "../base-store/base-store";
|
||||
import { BaseStore } from "../base-store/base-store";
|
||||
import { getOrInsertSet, toggle, toJS, object } from "../../renderer/utils";
|
||||
@ -84,19 +83,6 @@ export class UserStore extends BaseStore<UserStoreModel> /* implements UserStore
|
||||
*/
|
||||
@observable syncKubeconfigEntries!: StoreType<typeof DESCRIPTORS["syncKubeconfigEntries"]>;
|
||||
|
||||
startMainReactions() {
|
||||
// open at system start-up
|
||||
reaction(() => this.openAtLogin, openAtLogin => {
|
||||
app.setLoginItemSettings({
|
||||
openAtLogin,
|
||||
openAsHidden: true,
|
||||
args: ["--hidden"],
|
||||
});
|
||||
}, {
|
||||
fireImmediately: true,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a column (by ID) for a table (by ID) is configured to be hidden
|
||||
* @param tableId The ID of the table to be checked against
|
||||
|
||||
@ -8,4 +8,5 @@ import electronAppInjectable from "./electron-app.injectable";
|
||||
|
||||
export default getGlobalOverride(electronAppInjectable, () => ({
|
||||
getVersion: () => "6.0.0",
|
||||
} as Electron.App));
|
||||
setLoginItemSettings: () => {},
|
||||
} as Partial<Electron.App> as Electron.App));
|
||||
|
||||
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 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 type { Settings } from "electron";
|
||||
import electronAppInjectable from "../electron-app.injectable";
|
||||
|
||||
export type SetLoginItemSettings = (settings: Settings) => void;
|
||||
|
||||
const setLoginItemSettingsInjectable = getInjectable({
|
||||
id: "set-login-item-settings",
|
||||
instantiate: (di): SetLoginItemSettings => {
|
||||
const electronApp = di.inject(electronAppInjectable);
|
||||
|
||||
return (settings) => electronApp.setLoginItemSettings(settings);
|
||||
},
|
||||
});
|
||||
|
||||
export default setLoginItemSettingsInjectable;
|
||||
@ -1,26 +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 userStoreInjectable from "../../../common/user-store/user-store.injectable";
|
||||
import { onLoadOfApplicationInjectionToken } from "../runnable-tokens/on-load-of-application-injection-token";
|
||||
|
||||
const setupReactionsInUserStoreInjectable = getInjectable({
|
||||
id: "setup-reactions-in-user-store",
|
||||
|
||||
instantiate: (di) => {
|
||||
const userStore = di.inject(userStoreInjectable);
|
||||
|
||||
return {
|
||||
id: "setup-reactions-in-user-store",
|
||||
run: () => {
|
||||
userStore.startMainReactions();
|
||||
},
|
||||
};
|
||||
},
|
||||
|
||||
injectionToken: onLoadOfApplicationInjectionToken,
|
||||
});
|
||||
|
||||
export default setupReactionsInUserStoreInjectable;
|
||||
35
src/main/user-store/sync-open-at-login-with-os.injectable.ts
Normal file
35
src/main/user-store/sync-open-at-login-with-os.injectable.ts
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* 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 { reaction } from "mobx";
|
||||
import userStoreInjectable from "../../common/user-store/user-store.injectable";
|
||||
import setLoginItemSettingsInjectable from "../electron-app/features/set-login-item-settings.injectable";
|
||||
import { onLoadOfApplicationInjectionToken } from "../start-main-application/runnable-tokens/on-load-of-application-injection-token";
|
||||
|
||||
const setupSyncOpenAtLoginWithOsInjectable = getInjectable({
|
||||
id: "setup-sync-open-at-login-with-os",
|
||||
instantiate: (di) => {
|
||||
const setLoginItemSettings = di.inject(setLoginItemSettingsInjectable);
|
||||
const userStore = di.inject(userStoreInjectable);
|
||||
|
||||
return {
|
||||
id: "setup-sync-open-at-login-with-os",
|
||||
run: () => {
|
||||
reaction(() => userStore.openAtLogin, openAtLogin => {
|
||||
setLoginItemSettings({
|
||||
openAtLogin,
|
||||
openAsHidden: true,
|
||||
args: ["--hidden"],
|
||||
});
|
||||
}, {
|
||||
fireImmediately: true,
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
injectionToken: onLoadOfApplicationInjectionToken,
|
||||
});
|
||||
|
||||
export default setupSyncOpenAtLoginWithOsInjectable;
|
||||
Loading…
Reference in New Issue
Block a user