cancel subscriptions on signup popup destroy

This commit is contained in:
2025-06-03 23:28:12 +02:00
parent 54352d7b73
commit e09a232f3c
3 changed files with 12 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
import { rulesPopupState, rulesPopupRead } from './RulesPopup.ts';
import { rules } from '../../../rules.ts';
import { popupState } from '@components/popup/Popup.ts';
import { onDestroy } from 'svelte';
const modalTimeoutSeconds = 30;
@@ -10,7 +11,7 @@
let modalTimer = $state<ReturnType<typeof setInterval> | null>(null);
let modalSecondsOpen = $state(import.meta.env.PROD ? 0 : modalTimeoutSeconds);
rulesPopupState.listen((value) => {
const cancel = rulesPopupState.subscribe((value) => {
if (value == 'open') {
modalElem.show();
modalTimer = setInterval(() => modalSecondsOpen++, 1000);
@@ -18,10 +19,11 @@
clearInterval(modalTimer!);
}
});
onDestroy(cancel);
</script>
<dialog
id="rules-popup"
class="modal"
onclose={() => {
if ($rulesPopupState !== 'accepted') $rulesPopupState = 'closed';