fix: prevent age verification dialog flicker on page load

Initialize isOpen as false and only open in onMount if not yet verified,
instead of opening immediately and closing after localStorage check.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-06 16:52:48 +01:00
parent 7d373b3aa3
commit e943876e70

View File

@@ -13,7 +13,7 @@
const AGE_VERIFICATION_KEY = "age-verified";
let isOpen = true;
let isOpen = $state(false);
function handleAgeConfirmation() {
localStorage.setItem(AGE_VERIFICATION_KEY, "true");
@@ -21,9 +21,8 @@
}
onMount(() => {
const storedVerification = localStorage.getItem(AGE_VERIFICATION_KEY);
if (storedVerification === "true") {
isOpen = false;
if (localStorage.getItem(AGE_VERIFICATION_KEY) !== "true") {
isOpen = true;
}
});
</script>