Browse Source

navigate to profile from drawer

imwald
Silberengel 3 months ago
parent
commit
d55df7efd3
  1. 20
      src/PageManager.tsx

20
src/PageManager.tsx

@ -271,8 +271,27 @@ export function useSmartProfileNavigation() { @@ -271,8 +271,27 @@ export function useSmartProfileNavigation() {
const { setPrimaryNoteView } = usePrimaryNoteView()
const { push: pushSecondaryPage } = useSecondaryPage()
const { isSmallScreen } = useScreenSize()
const { closeDrawer, isDrawerOpen } = useNoteDrawer()
const navigateToProfile = (url: string) => {
// Close drawer if open (profiles aren't shown in drawers)
// Navigate after drawer closes to avoid URL being restored by drawer's onOpenChange
if (isDrawerOpen) {
closeDrawer()
// Wait for drawer to close (350ms animation) before navigating
setTimeout(() => {
if (isSmallScreen) {
// Use primary note view on mobile
const profileId = url.replace('/users/', '')
window.history.pushState(null, '', url)
setPrimaryNoteView(<SecondaryProfilePage id={profileId} index={0} hideTitlebar={true} />, 'profile')
} else {
// Use secondary routing on desktop
pushSecondaryPage(url)
}
}, 400) // Slightly longer than drawer close animation (350ms)
} else {
// No drawer open, navigate immediately
if (isSmallScreen) {
// Use primary note view on mobile
const profileId = url.replace('/users/', '')
@ -283,6 +302,7 @@ export function useSmartProfileNavigation() { @@ -283,6 +302,7 @@ export function useSmartProfileNavigation() {
pushSecondaryPage(url)
}
}
}
return { navigateToProfile }
}

Loading…
Cancel
Save