mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Handle failing download of update
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
f2dc3112e7
commit
7e64c1e57e
4 files changed
+79
-17
No files matched your search
@@ -53,7 +53,14 @@ const checkForUpdatesTrayItemInjectable = getInjectable({
|
||||
showNotification(`Download for version ${version} started...`);
|
||||
|
||||
// Note: intentional orphan promise to make download happen in the background
|
||||
versionUpdate.downloadUpdate().then(async () => {
|
||||
versionUpdate.downloadUpdate().then(async ({ downloadWasSuccessful }) => {
|
||||
|
||||
if (!downloadWasSuccessful) {
|
||||
showNotification(`Download for update failed`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const userWantsToInstallUpdate = await askBoolean(`Do you want to install update ${version}?`);
|
||||
|
||||
if (userWantsToInstallUpdate) {
|
||||
|
||||
@@ -55,6 +55,7 @@ const versionUpdateInjectable = getInjectable({
|
||||
downloadUpdate: downloadUpdateFor(
|
||||
downloadPlatformUpdate,
|
||||
downloadingUpdateState,
|
||||
discoveredVersionState,
|
||||
),
|
||||
};
|
||||
},
|
||||
@@ -66,17 +67,24 @@ const downloadUpdateFor =
|
||||
(
|
||||
downloadPlatformUpdate: () => Promise<{ downloadWasSuccessful: boolean }>,
|
||||
downloadingUpdateState: SyncBox<boolean>,
|
||||
discoveredVersionState: SyncBox<{ version: string; updateChannel: UpdateChannel }>,
|
||||
) =>
|
||||
async () => {
|
||||
runInAction(() => {
|
||||
downloadingUpdateState.set(true);
|
||||
});
|
||||
|
||||
await downloadPlatformUpdate();
|
||||
const { downloadWasSuccessful } = await downloadPlatformUpdate();
|
||||
|
||||
runInAction(() => {
|
||||
if (!downloadWasSuccessful) {
|
||||
discoveredVersionState.set(null);
|
||||
}
|
||||
|
||||
downloadingUpdateState.set(false);
|
||||
});
|
||||
|
||||
return { downloadWasSuccessful };
|
||||
};
|
||||
|
||||
const checkForUpdatesFor =
|
||||
|
||||
Reference in new issue
Block a user