#586 suggest alternative when auto update not working (#592)

* #586 suggest alternative when auto update not working

* add suggested strategy when calling quitAndInstall

---------

Co-authored-by: neil molina <neil@neils-MacBook-Pro.local>
This commit is contained in:
Neil 2023-05-16 08:05:55 +08:00 committed by GitHub
parent 67edf9971b
commit 3bd4a67238
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 2 deletions

View file

@ -93,7 +93,9 @@ export default function initializeHandlers({ notifyMainWindow }: HandlerOptions)
try {
log.info("relaunching app");
const autoUpdater = getUpdater();
await autoUpdater.quitAndInstall();
setImmediate(() => {
autoUpdater.quitAndInstall();
});
} catch (error) {
log.error(error);
}

View file

@ -4,6 +4,14 @@
import { appUpdateStore } from "$libs/stores";
const { updateStatus } = appUpdateStore;
let updateClickCount = 0;
const onRelaunch = async () => {
if (updateClickCount < 1) {
await relaunch();
}
updateClickCount++;
};
</script>
{#if $updateStatus.status === "up-to-date"}
@ -23,7 +31,7 @@
{:else if $updateStatus.status === "ready"}
<button
class="flex h-7 w-full items-center justify-between p-1 text-left outline-1 outline-gray hover:bg-gray hover:bg-opacity-25 hover:outline"
on:click={relaunch}
on:click={onRelaunch}
>
<div class="flex items-center">
<div class="circle-badge mr-2">1</div>
@ -35,6 +43,10 @@
</button>
{/if}
{#if $updateStatus.status === "ready" && updateClickCount >= 3}
<p class="p-1 text-xs text-primary">Force quit and relaunch the app, please.</p>
{/if}
<style>
.circle-badge {
display: flex;