mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Make quit triggered by auto update manifest as hard quit instead of just soft quit
Soft quit is the stand-by quit where only the renderer quits. Hard quit is the full quit of also main. Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
c90ab671ff
commit
f838a4eab5
14
src/main/electron-app/auto-updater.injectable.ts
Normal file
14
src/main/electron-app/auto-updater.injectable.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
/**
|
||||||
|
* 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 { autoUpdater } from "electron";
|
||||||
|
|
||||||
|
const autoUpdaterInjectable = getInjectable({
|
||||||
|
id: "auto-updater",
|
||||||
|
instantiate: () => autoUpdater,
|
||||||
|
causesSideEffects: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default autoUpdaterInjectable;
|
||||||
@ -4,9 +4,12 @@
|
|||||||
*/
|
*/
|
||||||
import { getInjectable } from "@ogre-tools/injectable";
|
import { getInjectable } from "@ogre-tools/injectable";
|
||||||
import electronAppInjectable from "./electron-app.injectable";
|
import electronAppInjectable from "./electron-app.injectable";
|
||||||
|
import isIntegrationTestingInjectable from "../../common/vars/is-integration-testing.injectable";
|
||||||
|
import autoUpdaterInjectable from "./auto-updater.injectable";
|
||||||
|
|
||||||
interface CallbackArgs {
|
interface CallbackArgs {
|
||||||
cancel: () => void;
|
cancel: () => void;
|
||||||
|
shouldOnlySoftQuit: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const whenApplicationWillQuitInjectable = getInjectable({
|
const whenApplicationWillQuitInjectable = getInjectable({
|
||||||
@ -15,10 +18,25 @@ const whenApplicationWillQuitInjectable = getInjectable({
|
|||||||
instantiate: (di) => {
|
instantiate: (di) => {
|
||||||
const app = di.inject(electronAppInjectable);
|
const app = di.inject(electronAppInjectable);
|
||||||
|
|
||||||
|
const isIntegrationTesting = di.inject(isIntegrationTestingInjectable);
|
||||||
|
const autoUpdater = di.inject(autoUpdaterInjectable);
|
||||||
|
|
||||||
|
let isAutoUpdating = false;
|
||||||
|
|
||||||
return (callback: (args: CallbackArgs) => void) => {
|
return (callback: (args: CallbackArgs) => void) => {
|
||||||
|
autoUpdater.on("before-quit-for-update", () => {
|
||||||
|
isAutoUpdating = true;
|
||||||
|
});
|
||||||
|
|
||||||
app.on("will-quit", (event) => {
|
app.on("will-quit", (event) => {
|
||||||
|
const shouldHardQuit = isIntegrationTesting || isAutoUpdating;
|
||||||
|
|
||||||
callback({
|
callback({
|
||||||
cancel: () => { event.preventDefault(); },
|
cancel: () => {
|
||||||
|
event.preventDefault();
|
||||||
|
},
|
||||||
|
|
||||||
|
shouldOnlySoftQuit: !shouldHardQuit,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import { beforeApplicationSoftQuitInjectionToken } from "../../before-applicatio
|
|||||||
import { runManyFor } from "../../run-many-for";
|
import { runManyFor } from "../../run-many-for";
|
||||||
import whenApplicationWillQuitInjectable from "../../../electron-app/when-application-will-quit.injectable";
|
import whenApplicationWillQuitInjectable from "../../../electron-app/when-application-will-quit.injectable";
|
||||||
import { beforeApplicationHardQuitInjectionToken } from "../../before-application-hard-quit/before-application-hard-quit-injection-token";
|
import { beforeApplicationHardQuitInjectionToken } from "../../before-application-hard-quit/before-application-hard-quit-injection-token";
|
||||||
import isIntegrationTestingInjectable from "../../../../common/vars/is-integration-testing.injectable";
|
|
||||||
|
|
||||||
const setupClosingOfApplicationInjectable = getInjectable({
|
const setupClosingOfApplicationInjectable = getInjectable({
|
||||||
id: "setup-closing-of-application",
|
id: "setup-closing-of-application",
|
||||||
@ -28,17 +27,12 @@ const setupClosingOfApplicationInjectable = getInjectable({
|
|||||||
beforeApplicationHardQuitInjectionToken,
|
beforeApplicationHardQuitInjectionToken,
|
||||||
);
|
);
|
||||||
|
|
||||||
const isIntegrationTesting = di.inject(isIntegrationTestingInjectable);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
run: () => {
|
run: () => {
|
||||||
whenApplicationWillQuit(async ({ cancel: cancelNativeQuit }) => {
|
whenApplicationWillQuit(async ({ cancel: cancelNativeQuit, shouldOnlySoftQuit }) => {
|
||||||
await runRunnablesBeforeApplicationSoftQuit();
|
await runRunnablesBeforeApplicationSoftQuit();
|
||||||
|
|
||||||
// &&!autoUpdateIsRunning) {
|
if (shouldOnlySoftQuit) {
|
||||||
const shouldDoOnlySoftQuit = !isIntegrationTesting;
|
|
||||||
|
|
||||||
if (shouldDoOnlySoftQuit) {
|
|
||||||
cancelNativeQuit();
|
cancelNativeQuit();
|
||||||
} else {
|
} else {
|
||||||
await runRunnablesBeforeApplicationHardQuit();
|
await runRunnablesBeforeApplicationHardQuit();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user