mirror of
https://github.com/gitbutlerapp/gitbutler.git
synced 2024-12-23 01:22:12 +03:00
fix: AppUpdater
popover not able to be closed (#4555)
This commit is contained in:
parent
3ba4297f1b
commit
ad92566cb3
@ -1,4 +1,5 @@
|
|||||||
import { showToast } from '$lib/notifications/toasts';
|
import { showToast } from '$lib/notifications/toasts';
|
||||||
|
import { getVersion } from '@tauri-apps/api/app';
|
||||||
import { relaunch } from '@tauri-apps/api/process';
|
import { relaunch } from '@tauri-apps/api/process';
|
||||||
import {
|
import {
|
||||||
checkUpdate,
|
checkUpdate,
|
||||||
@ -10,7 +11,7 @@ import {
|
|||||||
import posthog from 'posthog-js';
|
import posthog from 'posthog-js';
|
||||||
import { derived, writable, type Readable } from 'svelte/store';
|
import { derived, writable, type Readable } from 'svelte/store';
|
||||||
|
|
||||||
// TOOD: Investigate why 'DOWNLOADED' is not in the type provided by Tauri.
|
// TODO: Investigate why 'DOWNLOADED' is not in the type provided by Tauri.
|
||||||
export type Update =
|
export type Update =
|
||||||
| { version?: string; status?: UpdateStatus | 'DOWNLOADED'; body?: string }
|
| { version?: string; status?: UpdateStatus | 'DOWNLOADED'; body?: string }
|
||||||
| undefined;
|
| undefined;
|
||||||
@ -33,6 +34,7 @@ export class UpdaterService {
|
|||||||
undefined
|
undefined
|
||||||
);
|
);
|
||||||
|
|
||||||
|
currentVersion = writable<string | undefined>(undefined);
|
||||||
readonly version = derived(this.update, (update) => update?.version);
|
readonly version = derived(this.update, (update) => update?.version);
|
||||||
|
|
||||||
prev: Update | undefined;
|
prev: Update | undefined;
|
||||||
@ -42,6 +44,8 @@ export class UpdaterService {
|
|||||||
constructor() {}
|
constructor() {}
|
||||||
|
|
||||||
private async start() {
|
private async start() {
|
||||||
|
const currentVersion = await getVersion();
|
||||||
|
this.currentVersion.set(currentVersion);
|
||||||
await this.checkForUpdate();
|
await this.checkForUpdate();
|
||||||
setInterval(async () => await this.checkForUpdate(), 3600000); // hourly
|
setInterval(async () => await this.checkForUpdate(), 3600000); // hourly
|
||||||
this.unlistenFn = await onUpdaterEvent((status) => {
|
this.unlistenFn = await onUpdaterEvent((status) => {
|
||||||
|
@ -8,10 +8,13 @@
|
|||||||
const updaterService = getContext(UpdaterService);
|
const updaterService = getContext(UpdaterService);
|
||||||
const update = updaterService.update;
|
const update = updaterService.update;
|
||||||
const version = updaterService.version;
|
const version = updaterService.version;
|
||||||
|
const currentVersion = updaterService.currentVersion;
|
||||||
|
|
||||||
let dismissed = $state(false);
|
let dismissed = $state(false);
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (version && dismissed) dismissed = false;
|
if ($version !== $currentVersion && dismissed) {
|
||||||
|
dismissed = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -120,9 +123,8 @@
|
|||||||
Release notes
|
Release notes
|
||||||
</Button>
|
</Button>
|
||||||
<div class="status-section">
|
<div class="status-section">
|
||||||
<div class="sliding-gradient"></div>
|
|
||||||
|
|
||||||
{#if !$update.status}
|
{#if !$update.status}
|
||||||
|
<div class="sliding-gradient"></div>
|
||||||
<div class="cta-btn" transition:fade={{ duration: 100 }}>
|
<div class="cta-btn" transition:fade={{ duration: 100 }}>
|
||||||
<Button
|
<Button
|
||||||
wide
|
wide
|
||||||
@ -136,6 +138,7 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
{:else if $update.status === 'DONE'}
|
{:else if $update.status === 'DONE'}
|
||||||
|
<div class="sliding-gradient"></div>
|
||||||
<div class="cta-btn" transition:fade={{ duration: 100 }}>
|
<div class="cta-btn" transition:fade={{ duration: 100 }}>
|
||||||
<Button style="pop" kind="solid" wide on:click={() => updaterService.relaunchApp()}
|
<Button style="pop" kind="solid" wide on:click={() => updaterService.relaunchApp()}
|
||||||
>Restart</Button
|
>Restart</Button
|
||||||
@ -190,7 +193,6 @@
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
height: var(--size-button);
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-radius: var(--radius-m);
|
border-radius: var(--radius-m);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user