mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Make downloading of update and what follows more deliberate as orphan promise
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
2cd18c7245
commit
f23ee9c3ce
@ -13,6 +13,7 @@ import quitAndInstallUpdateInjectable from "../../electron-app/features/quit-and
|
|||||||
import downloadUpdateInjectable from "../download-update/download-update.injectable";
|
import downloadUpdateInjectable from "../download-update/download-update.injectable";
|
||||||
import broadcastChangeInUpdatingStatusInjectable from "./broadcast-change-in-updating-status.injectable";
|
import broadcastChangeInUpdatingStatusInjectable from "./broadcast-change-in-updating-status.injectable";
|
||||||
import checkForUpdatesStartingFromChannelInjectable from "./check-for-updates-starting-from-channel.injectable";
|
import checkForUpdatesStartingFromChannelInjectable from "./check-for-updates-starting-from-channel.injectable";
|
||||||
|
import withOrphanPromiseInjectable from "../../../common/utils/with-orphan-promise/with-orphan-promise";
|
||||||
|
|
||||||
const processCheckingForUpdatesInjectable = getInjectable({
|
const processCheckingForUpdatesInjectable = getInjectable({
|
||||||
id: "process-checking-for-updates",
|
id: "process-checking-for-updates",
|
||||||
@ -26,6 +27,7 @@ const processCheckingForUpdatesInjectable = getInjectable({
|
|||||||
const checkingForUpdatesState = di.inject(updatesAreBeingDiscoveredInjectable);
|
const checkingForUpdatesState = di.inject(updatesAreBeingDiscoveredInjectable);
|
||||||
const discoveredVersionState = di.inject(discoveredUpdateVersionInjectable);
|
const discoveredVersionState = di.inject(discoveredUpdateVersionInjectable);
|
||||||
const checkForUpdatesStartingFromChannel = di.inject(checkForUpdatesStartingFromChannelInjectable);
|
const checkForUpdatesStartingFromChannel = di.inject(checkForUpdatesStartingFromChannelInjectable);
|
||||||
|
const withOrphanPromise = di.inject(withOrphanPromiseInjectable);
|
||||||
|
|
||||||
return async () => {
|
return async () => {
|
||||||
broadcastChangeInUpdatingStatus({ eventId: "checking-for-updates" });
|
broadcastChangeInUpdatingStatus({ eventId: "checking-for-updates" });
|
||||||
@ -66,8 +68,9 @@ const processCheckingForUpdatesInjectable = getInjectable({
|
|||||||
checkingForUpdatesState.set(false);
|
checkingForUpdatesState.set(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Note: intentional orphan promise to make download happen in the background
|
withOrphanPromise(async () => {
|
||||||
downloadUpdate().then(async ({ downloadWasSuccessful }) => {
|
const { downloadWasSuccessful } = await downloadUpdate();
|
||||||
|
|
||||||
if (!downloadWasSuccessful) {
|
if (!downloadWasSuccessful) {
|
||||||
broadcastChangeInUpdatingStatus({
|
broadcastChangeInUpdatingStatus({
|
||||||
eventId: "download-for-update-failed",
|
eventId: "download-for-update-failed",
|
||||||
@ -86,7 +89,7 @@ const processCheckingForUpdatesInjectable = getInjectable({
|
|||||||
if (userWantsToInstallUpdate) {
|
if (userWantsToInstallUpdate) {
|
||||||
quitAndInstallUpdate();
|
quitAndInstallUpdate();
|
||||||
}
|
}
|
||||||
});
|
})();
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user