@@ -88,25 +88,24 @@ const navItems = [
8888 import { isUsernameBanned } from '../utils/blacklist.js';
8989
9090 const provider = new GoogleAuthProvider();
91- const shell = document.querySelector('[data-profile-shell]');
92- if (!shell) console.warn('Profile shell bulunamadı, profil init atlandı.');
9391
94- const userPanel = shell?.querySelector('[data-user-panel]');
95- const authGuard = shell?.querySelector('[data-auth-guard]');
96- const dashboard = shell?.querySelector('[data-dashboard]');
97- const userAvatar = shell?.querySelector('[data-user-avatar]');
98- const userFallback = shell?.querySelector('[data-user-fallback]');
99- const userName = shell?.querySelector('[data-user-name]');
100- const userEmail = shell?.querySelector('[data-user-email]');
101- const userHandle = shell?.querySelector('[data-user-handle]');
102- const usernameClaim = shell?.querySelector('[data-username-claim]');
103- const usernameInput = shell?.querySelector('[data-username-input]');
104- const usernameSaveBtn = shell?.querySelector('[data-username-save]');
105- const usernameMsg = shell?.querySelector('[data-username-msg]');
106- const likesList = shell?.querySelector('[data-likes-list]');
107- const likeCount = shell?.querySelector('[data-like-count]');
108- const loginBtn = shell?.querySelector('[data-login-btn]');
109- const logoutBtn = document.querySelector('[data-logout-btn]');
92+ let shell = null;
93+ let userPanel = null;
94+ let authGuard = null;
95+ let dashboard = null;
96+ let userAvatar = null;
97+ let userFallback = null;
98+ let userName = null;
99+ let userEmail = null;
100+ let userHandle = null;
101+ let usernameClaim = null;
102+ let usernameInput = null;
103+ let usernameSaveBtn = null;
104+ let usernameMsg = null;
105+ let likesList = null;
106+ let likeCount = null;
107+ let loginBtn = null;
108+ let logoutBtn = null;
110109
111110 let likesUnsub = null;
112111 let authUnsub = null;
@@ -206,7 +205,29 @@ const navItems = [
206205 };
207206
208207 const bootProfile = async () => {
209- if (!shell) return;
208+ shell = document.querySelector('[data-profile-shell]');
209+ if (!shell) {
210+ console.warn('Profile shell bulunamadı, profil init atlandı.');
211+ return;
212+ }
213+
214+ userPanel = shell.querySelector('[data-user-panel]');
215+ authGuard = shell.querySelector('[data-auth-guard]');
216+ dashboard = shell.querySelector('[data-dashboard]');
217+ userAvatar = shell.querySelector('[data-user-avatar]');
218+ userFallback = shell.querySelector('[data-user-fallback]');
219+ userName = shell.querySelector('[data-user-name]');
220+ userEmail = shell.querySelector('[data-user-email]');
221+ userHandle = shell.querySelector('[data-user-handle]');
222+ usernameClaim = shell.querySelector('[data-username-claim]');
223+ usernameInput = shell.querySelector('[data-username-input]');
224+ usernameSaveBtn = shell.querySelector('[data-username-save]');
225+ usernameMsg = shell.querySelector('[data-username-msg]');
226+ likesList = shell.querySelector('[data-likes-list]');
227+ likeCount = shell.querySelector('[data-like-count]');
228+ loginBtn = shell.querySelector('[data-login-btn]');
229+ logoutBtn = document.querySelector('[data-logout-btn]');
230+
210231 if (loginBtn && !loginBtn.dataset.bound) {
211232 loginBtn.dataset.bound = '1';
212233 loginBtn.addEventListener('click', async () => { try { await signInWithPopup(auth, provider); } catch (error) { console.error('Giriş hatası:', error); } });
@@ -252,7 +273,28 @@ const navItems = [
252273 });
253274 };
254275
255- const cleanupProfile = () => { cleanupLikesListener(); if (authUnsub) { try { authUnsub(); } catch {} authUnsub = null; } currentUser = null; };
276+ const cleanupProfile = () => {
277+ cleanupLikesListener();
278+ if (authUnsub) { try { authUnsub(); } catch {} authUnsub = null; }
279+ currentUser = null;
280+ shell = null;
281+ userPanel = null;
282+ authGuard = null;
283+ dashboard = null;
284+ userAvatar = null;
285+ userFallback = null;
286+ userName = null;
287+ userEmail = null;
288+ userHandle = null;
289+ usernameClaim = null;
290+ usernameInput = null;
291+ usernameSaveBtn = null;
292+ usernameMsg = null;
293+ likesList = null;
294+ likeCount = null;
295+ loginBtn = null;
296+ logoutBtn = null;
297+ };
256298 bootProfile(); document.addEventListener('astro:page-load', bootProfile); document.addEventListener('astro:before-swap', cleanupProfile);
257299 </script >
258300 </AppShell >
0 commit comments