From 755c791af54f3d7a06d9621e13d6de0fcab54580 Mon Sep 17 00:00:00 2001 From: Elijah Date: Sat, 23 May 2026 17:23:49 -0700 Subject: [PATCH] fix(ui): use pushState for folder navigation in public share links --- frontend/src/app/share/[id]/page.tsx | 29 +++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/share/[id]/page.tsx b/frontend/src/app/share/[id]/page.tsx index 6dc9ba5..e327536 100644 --- a/frontend/src/app/share/[id]/page.tsx +++ b/frontend/src/app/share/[id]/page.tsx @@ -26,6 +26,29 @@ export default function PublicSharePage({ params }: { params: Promise<{ id: stri const [fileInfo, setFileInfo] = useState(null); const [currentPath, setCurrentPath] = useState(''); + useEffect(() => { + const handlePopState = (e: PopStateEvent) => { + if (e.state && e.state.path !== undefined) { + setCurrentPath(e.state.path); + } else { + setCurrentPath(new URLSearchParams(window.location.search).get('path') || ''); + } + }; + window.addEventListener('popstate', handlePopState); + + // Initial sync + const urlPath = new URLSearchParams(window.location.search).get('path'); + if (urlPath && urlPath !== currentPath) { + setCurrentPath(urlPath); + } + return () => window.removeEventListener('popstate', handlePopState); + }, []); + + const navigateTo = (path: string) => { + setCurrentPath(path); + window.history.pushState({ path }, '', path ? `?path=${encodeURIComponent(path)}` : window.location.pathname); + }; + useEffect(() => { if (lockoutTime <= 0) return; const timer = setInterval(() => { @@ -199,7 +222,7 @@ export default function PublicSharePage({ params }: { params: Promise<{ id: stri {fileInfo?.is_dir && (
- @@ -209,7 +232,7 @@ export default function PublicSharePage({ params }: { params: Promise<{ id: stri