Browse Source

navigate to profile from drawer

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

34
src/PageManager.tsx

@ -271,16 +271,36 @@ export function useSmartProfileNavigation() {
const { setPrimaryNoteView } = usePrimaryNoteView() const { setPrimaryNoteView } = usePrimaryNoteView()
const { push: pushSecondaryPage } = useSecondaryPage() const { push: pushSecondaryPage } = useSecondaryPage()
const { isSmallScreen } = useScreenSize() const { isSmallScreen } = useScreenSize()
const { closeDrawer, isDrawerOpen } = useNoteDrawer()
const navigateToProfile = (url: string) => { const navigateToProfile = (url: string) => {
if (isSmallScreen) { // Close drawer if open (profiles aren't shown in drawers)
// Use primary note view on mobile // Navigate after drawer closes to avoid URL being restored by drawer's onOpenChange
const profileId = url.replace('/users/', '') if (isDrawerOpen) {
window.history.pushState(null, '', url) closeDrawer()
setPrimaryNoteView(<SecondaryProfilePage id={profileId} index={0} hideTitlebar={true} />, 'profile') // 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 { } else {
// Use secondary routing on desktop // No drawer open, navigate immediately
pushSecondaryPage(url) 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)
}
} }
} }

Loading…
Cancel
Save