diff --git a/src/lib/components/ChangelogModal.svelte b/src/lib/components/ChangelogModal.svelte index ada9d122d2..274abcdfd9 100644 --- a/src/lib/components/ChangelogModal.svelte +++ b/src/lib/components/ChangelogModal.svelte @@ -2,7 +2,6 @@ import DOMPurify from 'dompurify'; import { onMount, getContext } from 'svelte'; - import { Confetti } from 'svelte-confetti'; import { WEBUI_NAME, config, settings } from '$lib/stores'; @@ -18,9 +17,17 @@ export let show = false; let changelog = null; + let error = false; const init = async () => { - changelog = await getChangelog(); + if (changelog || error) { + return; + } + + changelog = await getChangelog().catch(() => { + error = true; + return null; + }); }; const closeModal = async () => { @@ -33,81 +40,126 @@ $: if (show) { init(); } + + const formatDate = (date) => { + if (!date) { + return ''; + } + + const [year, month, day] = date.split('-'); + const months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; + const monthIndex = Number(month) - 1; + + return year && monthIndex >= 0 && monthIndex < months.length && day + ? `${months[monthIndex]} ${Number(day)}, ${year}` + : date; + }; - -
-
-

- {$i18n.t("What's New in")} - {$WEBUI_NAME} - -

+ +
+
+
+

+ {$i18n.t("What's New in")} {$WEBUI_NAME} +

+
+ {$i18n.t('Release Notes')} + + v{WEBUI_VERSION} +
+
+
-
-
{$i18n.t('Release Notes')}
-
-
- v{WEBUI_VERSION} -
-
-
-
-
-
- {#if changelog} +
+ {#if changelog} +
{#each Object.keys(changelog) as version} -
-

- v{version} - {changelog[version].date} -

- -
+
+
+

v{version}

+
+ {formatDate(changelog[version].date)} +
+
{#each Object.keys(changelog[version]).filter((section) => section !== 'date') as section} -
+
{section}
-
+
{#each changelog[version][section] as entry} -
- {@html DOMPurify.sanitize(entry?.raw)} +
+ +
+ {@html DOMPurify.sanitize(entry?.raw)} +
{/each}
{/each} -
+
{/each} - {/if} -
+
+ {:else if error} +
+

+ {$i18n.t('Could not load release notes.')} +

+ +
+ {:else} +
+ {$i18n.t('Loading release notes...')} +
+ {/if}
-
+ +