diff --git a/src/app.html b/src/app.html index 415659d..8e7adfc 100644 --- a/src/app.html +++ b/src/app.html @@ -23,14 +23,4 @@
%sveltekit.body%
- - - diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index dca9b77..4078cf4 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -34,21 +34,25 @@ }); let showConsentModal = false; + let allowAnalytics = false; function rememberChoice(allow: boolean) { localStorage.setItem('analytics', allow.toString()); showConsentModal = false; - - if (allow) location.reload(); + allowAnalytics = allow; } onMount(() => { new DateTriggerEventHandler(themeEvents); // Check if the user has already decided. - + // Check if the user has already decided const hasDecided = localStorage.getItem('analytics') !== null; - if (!hasDecided) showConsentModal = true; + if (hasDecided) { + allowAnalytics = localStorage.getItem('analytics') === 'true'; + } else { + showConsentModal = true; + } isRestoring.set(true); const [unsubscribe, promise] = persistQueryClient({ @@ -76,22 +80,24 @@ - - + {#if allowAnalytics} + + + {/if} @@ -117,3 +123,15 @@ +{#if allowAnalytics} + + +{/if}