From 69d62eaa5c97ab20c1c511b85f58119a0f14c0bb Mon Sep 17 00:00:00 2001 From: ergosteur <1992147+ergosteur@users.noreply.github.com> Date: Sat, 7 Mar 2026 05:10:43 -0500 Subject: [PATCH] fix: improve permalink comparison and add debug logging --- src/App.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 2777000..604d1c6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -657,17 +657,21 @@ export default function App() { useEffect(() => { const params = new URLSearchParams(); if (currentArchive) params.set('a', currentArchive.name); + else if (allPosts.length > 0 && username) params.set('a', username); // Handle local archives too + if (activeTab !== 'posts') params.set('t', activeTab); if (selectedPost) params.set('p', selectedPost.id); const newSearch = params.toString(); - const currentSearch = window.location.search.replace(/^\?/, ''); + // Normalize currentSearch to ensure we don't have mismatch due to encoding + const currentSearch = new URLSearchParams(window.location.search).toString(); if (newSearch !== currentSearch) { + console.log(`[Permalink] Updating URL state: ?${newSearch}`); const newUrl = window.location.pathname + (newSearch ? `?${newSearch}` : ''); window.history.replaceState(null, '', newUrl); } - }, [currentArchive?.name, activeTab, selectedPost?.id]); + }, [currentArchive?.name, username, allPosts.length, activeTab, selectedPost?.id]); // Read state from URL on mount/initialization const [hasInitialLoaded, setHasInitialLoaded] = useState(false);