mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
chore: Move is auto updating state to own injectable
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
a81b0f961e
commit
8ee65f841e
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 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";
|
||||
|
||||
const isAutoUpdatingInjectable = getInjectable({
|
||||
id: "is-auto-updating",
|
||||
instantiate: () => {
|
||||
let value = false;
|
||||
|
||||
return {
|
||||
get: () => value,
|
||||
setAsUpdating: () => {
|
||||
value = true;
|
||||
},
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
export default isAutoUpdatingInjectable;
|
||||
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-electron-main";
|
||||
import { getInjectable } from "@ogre-tools/injectable";
|
||||
import autoUpdaterInjectable from "./auto-updater.injectable";
|
||||
import isAutoUpdatingInjectable from "./is-auto-updating.injectable";
|
||||
|
||||
const setupTrackingOfAutoUpdatingInjectable = getInjectable({
|
||||
id: "setup-tracking-of-auto-updating",
|
||||
instantiate: (di) => ({
|
||||
run: () => {
|
||||
const autoUpdater = di.inject(autoUpdaterInjectable);
|
||||
const isAutoUpdating = di.inject(isAutoUpdatingInjectable);
|
||||
|
||||
autoUpdater.once("before-quit-for-update", () => {
|
||||
isAutoUpdating.setAsUpdating();
|
||||
});
|
||||
|
||||
return undefined;
|
||||
},
|
||||
}),
|
||||
injectionToken: beforeElectronIsReadyInjectionToken,
|
||||
});
|
||||
|
||||
export default setupTrackingOfAutoUpdatingInjectable;
|
||||
@ -7,8 +7,8 @@ import { beforeElectronIsReadyInjectionToken } from "@k8slens/application-for-el
|
||||
import { afterQuitOfFrontEndInjectionToken, onQuitOfBackEndInjectionToken } from "../../start-main-application/runnable-tokens/phases";
|
||||
import electronAppInjectable from "../electron-app.injectable";
|
||||
import isIntegrationTestingInjectable from "../../../common/vars/is-integration-testing.injectable";
|
||||
import autoUpdaterInjectable from "../features/auto-updater.injectable";
|
||||
import { runManySyncFor, runManyFor } from "@k8slens/run-many";
|
||||
import isAutoUpdatingInjectable from "../features/is-auto-updating.injectable";
|
||||
|
||||
const setupRunnablesBeforeClosingOfApplicationInjectable = getInjectable({
|
||||
id: "setup-closing-of-application",
|
||||
@ -21,12 +21,7 @@ const setupRunnablesBeforeClosingOfApplicationInjectable = getInjectable({
|
||||
const runOnQuitOfBackEnd = runMany(onQuitOfBackEndInjectionToken);
|
||||
const app = di.inject(electronAppInjectable);
|
||||
const isIntegrationTesting = di.inject(isIntegrationTestingInjectable);
|
||||
const autoUpdater = di.inject(autoUpdaterInjectable);
|
||||
let isAutoUpdating = false;
|
||||
|
||||
autoUpdater.on("before-quit-for-update", () => {
|
||||
isAutoUpdating = true;
|
||||
});
|
||||
const isAutoUpdating = di.inject(isAutoUpdatingInjectable);
|
||||
|
||||
app.on("will-quit", () => {
|
||||
runAfterQuitOfFrontEnd();
|
||||
@ -56,7 +51,7 @@ const setupRunnablesBeforeClosingOfApplicationInjectable = getInjectable({
|
||||
runAfterQuitOfFrontEnd();
|
||||
event.preventDefault();
|
||||
|
||||
if (isIntegrationTesting || isAutoUpdating) {
|
||||
if (isIntegrationTesting || isAutoUpdating.get()) {
|
||||
doAsyncQuit(event);
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user