better handling of frontend updates, following svelte docs

This commit is contained in:
Jan Kessler
2025-05-13 07:48:29 +02:00
parent a904f874ee
commit dfd4037132
3 changed files with 20 additions and 1 deletions

View File

@@ -49,6 +49,16 @@
import AppSidebar from '$lib/components/app/AppSidebar.svelte';
import { chatCompletion } from '$lib/apis/openai';
import { beforeNavigate } from '$app/navigation';
import { updated } from '$app/state';
// handle frontend updates (https://svelte.dev/docs/kit/configuration#version)
beforeNavigate(({ willUnload, to }) => {
if (updated.current && !willUnload && to?.url) {
location.href = to.url.href;
}
});
setContext('i18n', i18n);
const bc = new BroadcastChannel('active-tab-channel');