Commit 1325db19 authored by Mahmoud Aglan's avatar Mahmoud Aglan

fix: add unmount cleanup for timer-leaking scenes (#63, #91, #204-206)

- tournament-arena, tournament-lobby, tournament-live: export unmount
- group-chat: export unmount to clear realtime sub + invite timer
- social/mod.js: register unmountChat and unmountGroupChat
- Prevents interval leaks when navigating away from these scenes
Co-Authored-By: 's avatarClaude Opus 4.6 <noreply@anthropic.com>
parent 7df3c582
......@@ -158,3 +158,5 @@ function cleanup() {
if (pollInterval) { clearInterval(pollInterval); pollInterval = null; }
if (countdownInterval) { clearInterval(countdownInterval); countdownInterval = null; }
}
export const unmountTournamentArena = cleanup;
......@@ -133,3 +133,7 @@ async function loadLiveData(el, tournamentId) {
content.innerHTML = '<div style="text-align:center;color:var(--error);">فشل التحميل</div>';
}
}
export function unmountTournamentLive() {
if (refreshInterval) { clearInterval(refreshInterval); refreshInterval = null; }
}
......@@ -116,3 +116,5 @@ function cleanup() {
if (countdownInterval) { clearInterval(countdownInterval); countdownInterval = null; }
if (unsub) { unsub(); unsub = null; }
}
export const unmountTournamentLobby = cleanup;
......@@ -2,17 +2,17 @@ import * as scene from '../../core/scene.js';
import { mountFriends, unmountFriends } from './scenes/friends.js';
import { mountNotifications } from './scenes/notifications.js';
import { mountActivity } from './scenes/activity.js';
import { mountChat } from './scenes/chat.js';
import { mountChat, unmountChat } from './scenes/chat.js';
import { mountGroups } from './scenes/groups.js';
import { mountGroupCreate } from './scenes/group-create.js';
import { mountGroupChat } from './scenes/group-chat.js';
import { mountGroupChat, unmountGroupChat } from './scenes/group-chat.js';
import { mountGroupMembers } from './scenes/group-members.js';
scene.register('friends', mountFriends, unmountFriends);
scene.register('notifications', mountNotifications);
scene.register('activity-feed', mountActivity);
scene.register('friend-chat', mountChat);
scene.register('friend-chat', mountChat, unmountChat);
scene.register('groups', mountGroups);
scene.register('group-create', mountGroupCreate);
scene.register('group-chat', mountGroupChat);
scene.register('group-chat', mountGroupChat, unmountGroupChat);
scene.register('group-members', mountGroupMembers);
......@@ -297,6 +297,8 @@ function cleanup() {
if (inviteTimer) { clearInterval(inviteTimer); inviteTimer = null; }
}
export const unmountGroupChat = cleanup;
function escapeHtml(str) {
const div = document.createElement('div');
div.textContent = str;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment