Skip to content

Commit

Permalink
fix: don't hide app updater pop-up entirely in flatpak package
Browse files Browse the repository at this point in the history
  • Loading branch information
ndom91 committed Jan 22, 2025
1 parent 80cff10 commit a65e2e4
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 38 deletions.
79 changes: 42 additions & 37 deletions apps/desktop/src/components/AppUpdater.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import { getContext } from '@gitbutler/shared/context';
import Button from '@gitbutler/ui/Button.svelte';
import { fade } from 'svelte/transition';
import { env } from '$env/dynamic/public';
const updaterService = getContext(UpdaterService);
const update = updaterService.update;
Expand All @@ -20,6 +21,8 @@
function handleDismiss() {
updaterService.dismiss();
}
const inFlatpak = $derived(!!env.PUBLIC_FLATPAK_ID);
</script>

{#if version || status === 'Up-to-date'}
Expand Down Expand Up @@ -130,45 +133,47 @@
Release notes
</Button>
{/if}
<div class="status-section">
{#if status !== 'Error' && status !== 'Up-to-date'}
<div class="sliding-gradient"></div>
{/if}
<div class="cta-btn" transition:fade={{ duration: 100 }}>
{#if !status}
<Button
wide
style="pop"
testId="download-update"
onmousedown={async () => {
await updaterService.downloadAndInstall();
}}
>
Update to {version}
</Button>
{:else if status === 'Up-to-date'}
<Button
wide
style="pop"
testId="got-it"
onmousedown={async () => {
updaterService.dismiss();
}}
>
Got it!
</Button>
{:else if status === 'Done'}
<Button
style="pop"
wide
testId="restart-app"
onclick={async () => await updaterService.relaunchApp()}
>
Restart
</Button>
{#if !inFlatpak}
<div class="status-section">
{#if status !== 'Error' && status !== 'Up-to-date'}
<div class="sliding-gradient"></div>
{/if}
<div class="cta-btn" transition:fade={{ duration: 100 }}>
{#if !status}
<Button
wide
style="pop"
testId="download-update"
onmousedown={async () => {
await updaterService.downloadAndInstall();
}}
>
Update to {version}
</Button>
{:else if status === 'Up-to-date'}
<Button
wide
style="pop"
testId="got-it"
onmousedown={async () => {
updaterService.dismiss();
}}
>
Got it!
</Button>
{:else if status === 'Done'}
<Button
style="pop"
wide
testId="restart-app"
onclick={async () => await updaterService.relaunchApp()}
>
Restart
</Button>
{/if}
</div>
</div>
</div>
{/if}
</div>
</div>
{/if}
Expand Down
7 changes: 7 additions & 0 deletions apps/desktop/src/components/AppUpdater.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ describe('AppUpdater', () => {
updater = new UpdaterService(tauri, posthog);
context = new Map([[UpdaterService, updater]]);
vi.spyOn(tauri, 'listen').mockReturnValue(async () => {});
vi.mock('$env/dynamic/public', () => {
return {
env: {
PUBLIC_FLATPAK_ID: undefined
}
};
});
});

afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/src/lib/backend/tauri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ import { check } from '@tauri-apps/plugin-updater';
export class Tauri {
invoke = invokeIpc;
listen = listenIpc;
checkUpdate = import.meta.env.VITE_FLATPAK_ID ? () => null : check;
checkUpdate = check;
currentVersion = getVersion;
}

0 comments on commit a65e2e4

Please sign in to comment.