Open application only if new update is available when using tray to check for updates (#5948)

* Prevent opening of application if no new updates were downloaded when checking for updates using tray when application window is closed

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Fix getting initial value of sync box

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Tweak naming of variable

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen authored and GitHub committed 2022-07-29 15:55:16 +03:00
1 parent a68ce2b2be
commit af4b74d9bd
8 files changed
+110 -52

No files matched your search

@@ -59,9 +59,11 @@ const checkForUpdatesTrayItemInjectable = getInjectable({
click: pipeline(
async () => {
await processCheckingForUpdates("tray");
const { updateIsReadyToBeInstalled } = await processCheckingForUpdates("tray");
await showApplicationWindow();
if (updateIsReadyToBeInstalled) {
await showApplicationWindow();
}
},
withErrorLoggingFor(() => "[TRAY]: Checking for updates failed."),
@@ -9,7 +9,6 @@ import discoveredUpdateVersionInjectable from "../../../common/application-updat
import { runInAction } from "mobx";
import downloadUpdateInjectable from "../download-update/download-update.injectable";
import checkForUpdatesStartingFromChannelInjectable from "./check-for-updates-starting-from-channel.injectable";
import withOrphanPromiseInjectable from "../../../common/utils/with-orphan-promise/with-orphan-promise.injectable";
import emitEventInjectable from "../../../common/app-event-bus/emit-event.injectable";
import { getCurrentDateTime } from "../../../common/utils/date/get-current-date-time";
@@ -22,7 +21,6 @@ const processCheckingForUpdatesInjectable = getInjectable({
const checkingForUpdatesState = di.inject(updatesAreBeingDiscoveredInjectable);
const discoveredVersionState = di.inject(discoveredUpdateVersionInjectable);
const checkForUpdatesStartingFromChannel = di.inject(checkForUpdatesStartingFromChannelInjectable);
const withOrphanPromise = di.inject(withOrphanPromiseInjectable);
const emitEvent = di.inject(emitEventInjectable);
return async (source: string) => {
@@ -44,7 +42,7 @@ const processCheckingForUpdatesInjectable = getInjectable({
checkingForUpdatesState.set(false);
});
return;
return { updateIsReadyToBeInstalled: false };
}
const { version, actualUpdateChannel } = result;
@@ -56,7 +54,7 @@ const processCheckingForUpdatesInjectable = getInjectable({
checkingForUpdatesState.set(false);
});
return;
return { updateIsReadyToBeInstalled: true };
}
emitEvent({
@@ -74,7 +72,9 @@ const processCheckingForUpdatesInjectable = getInjectable({
checkingForUpdatesState.set(false);
});
withOrphanPromise(async () => await downloadUpdate())();
const { downloadWasSuccessful } = await downloadUpdate();
return { updateIsReadyToBeInstalled: downloadWasSuccessful };
};
},
});