-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #153 from WhyAsh5114/changelog-section
feat: changelog section and QOL
- Loading branch information
Showing
13 changed files
with
199 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { browser } from '$app/environment'; | ||
import { useRegisterSW } from 'virtual:pwa-register/svelte'; | ||
|
||
const sw = browser | ||
? useRegisterSW({ | ||
onRegisteredSW(swUrl, r) { | ||
if (r) { | ||
setInterval(async () => { | ||
if (!navigator || r.installing) return; | ||
if ('connection' in navigator && !navigator.onLine) return; | ||
|
||
const resp = await fetch(swUrl, { | ||
cache: 'no-store', | ||
headers: { | ||
cache: 'no-store', | ||
'cache-control': 'no-cache' | ||
} | ||
}); | ||
if (resp.status === 200) await r.update(); | ||
}, 3600000); | ||
} | ||
console.log(`SW Registered: ${r}`); | ||
}, | ||
onRegisterError(error) { | ||
console.log('SW registration error', error); | ||
} | ||
}) | ||
: null; | ||
|
||
export const needRefresh = sw?.needRefresh; | ||
export const updateServiceWorker = sw?.updateServiceWorker; | ||
export const offlineReady = sw?.offlineReady; | ||
export const updateDataLossDialog = $state({ open: false }); |
27 changes: 27 additions & 0 deletions
27
src/routes/(components)/layout/UpdateDataLossDialog.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script lang="ts"> | ||
import ResponsiveDialog from '$lib/components/ResponsiveDialog.svelte'; | ||
import Button from '$lib/components/ui/button/button.svelte'; | ||
import LoaderCircle from 'virtual:icons/lucide/loader-circle'; | ||
import { updateDataLossDialog, updateServiceWorker } from './PWAFunctions.svelte'; | ||
let updating = $state(false); | ||
function updateApp() { | ||
updating = true; | ||
localStorage.clear(); | ||
updateServiceWorker!(true); | ||
} | ||
</script> | ||
|
||
<ResponsiveDialog title="Update app?" bind:open={updateDataLossDialog.open}> | ||
{#snippet description()} | ||
<p>Any unsaved data, like a workout in progress, or an unsaved mesocycle will be lost.</p> | ||
{/snippet} | ||
<Button disabled={updating} onclick={updateApp} class="gap-2"> | ||
{#if updating} | ||
<LoaderCircle class="animate-spin" /> | ||
{:else} | ||
Update | ||
{/if} | ||
</Button> | ||
</ResponsiveDialog> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export const prerender = true; | ||
|
||
type ReleaseData = { body: string; published_at: string; tag_name: string }; | ||
|
||
export const load = async () => { | ||
const response = await fetch('https://api.github.com/repos/WhyAsh5114/MyFit/releases'); | ||
const body = await response.json(); | ||
const releases = body.map(({ body, published_at, tag_name }: ReleaseData) => ({ | ||
body, | ||
published_at, | ||
tag_name | ||
})) as ReleaseData[]; | ||
return { releases }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<script lang="ts"> | ||
import Separator from '$lib/components/ui/separator/separator.svelte'; | ||
import H2 from '$lib/components/ui/typography/H2.svelte'; | ||
import DOMPurify from 'dompurify'; | ||
import { marked } from 'marked'; | ||
let { data } = $props(); | ||
</script> | ||
|
||
<H2>Changelog</H2> | ||
{#each data.releases as { body }, idx} | ||
<article class="prose prose-sm dark:prose-invert md:prose-base"> | ||
{#await marked.parse(body) then body} | ||
{@html DOMPurify.sanitize(body)} | ||
{/await} | ||
</article> | ||
{#if idx !== data.releases.length - 1} | ||
<Separator class="my-6" /> | ||
{/if} | ||
{/each} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters