From 55bef7f887dd38fa71fdd0a89961b7b9be7ab55f Mon Sep 17 00:00:00 2001 From: Silberengel Date: Sun, 26 Oct 2025 09:40:33 +0100 Subject: [PATCH] fix profile nav links --- src/PageManager.tsx | 67 ++++++++++++++++++++++ src/components/Profile/SmartFollowings.tsx | 6 +- src/components/Profile/SmartMuteLink.tsx | 6 +- src/components/Profile/SmartRelays.tsx | 12 ++-- 4 files changed, 78 insertions(+), 13 deletions(-) diff --git a/src/PageManager.tsx b/src/PageManager.tsx index 38979af..2151bf0 100644 --- a/src/PageManager.tsx +++ b/src/PageManager.tsx @@ -12,6 +12,9 @@ import PostSettingsPage from '@/pages/secondary/PostSettingsPage' import GeneralSettingsPage from '@/pages/secondary/GeneralSettingsPage' import TranslationPage from '@/pages/secondary/TranslationPage' import SecondaryProfilePage from '@/pages/secondary/ProfilePage' +import FollowingListPage from '@/pages/secondary/FollowingListPage' +import MuteListPage from '@/pages/secondary/MuteListPage' +import OthersRelaySettingsPage from '@/pages/secondary/OthersRelaySettingsPage' import { CurrentRelaysProvider } from '@/providers/CurrentRelaysProvider' import { NotificationProvider } from '@/providers/NotificationProvider' import { useUserPreferences } from '@/providers/UserPreferencesProvider' @@ -208,6 +211,70 @@ export function useSmartHashtagNavigation() { return { navigateToHashtag } } +// Custom hook for intelligent following list navigation +export function useSmartFollowingListNavigation() { + const { showRecommendedRelaysPanel } = useUserPreferences() + const { push: pushSecondary } = useSecondaryPage() + const { setPrimaryNoteView } = usePrimaryNoteView() + + const navigateToFollowingList = (url: string) => { + if (!showRecommendedRelaysPanel) { + // When right panel is hidden, show following list in primary area + // Extract profile ID from URL (e.g., "/users/npub1.../following" -> "npub1...") + const profileId = url.replace('/users/', '').replace('/following', '') + window.history.replaceState(null, '', url) + setPrimaryNoteView(, 'profile') + } else { + // Normal behavior - use secondary navigation + pushSecondary(url) + } + } + + return { navigateToFollowingList } +} + +// Custom hook for intelligent mute list navigation +export function useSmartMuteListNavigation() { + const { showRecommendedRelaysPanel } = useUserPreferences() + const { push: pushSecondary } = useSecondaryPage() + const { setPrimaryNoteView } = usePrimaryNoteView() + + const navigateToMuteList = (url: string) => { + if (!showRecommendedRelaysPanel) { + // When right panel is hidden, show mute list in primary area + window.history.replaceState(null, '', url) + setPrimaryNoteView(, 'settings') + } else { + // Normal behavior - use secondary navigation + pushSecondary(url) + } + } + + return { navigateToMuteList } +} + +// Custom hook for intelligent others relay settings navigation +export function useSmartOthersRelaySettingsNavigation() { + const { showRecommendedRelaysPanel } = useUserPreferences() + const { push: pushSecondary } = useSecondaryPage() + const { setPrimaryNoteView } = usePrimaryNoteView() + + const navigateToOthersRelaySettings = (url: string) => { + if (!showRecommendedRelaysPanel) { + // When right panel is hidden, show others relay settings in primary area + // Extract profile ID from URL (e.g., "/users/npub1.../relays" -> "npub1...") + const profileId = url.replace('/users/', '').replace('/relays', '') + window.history.replaceState(null, '', url) + setPrimaryNoteView(, 'profile') + } else { + // Normal behavior - use secondary navigation + pushSecondary(url) + } + } + + return { navigateToOthersRelaySettings } +} + // Custom hook for intelligent settings navigation export function useSmartSettingsNavigation() { const { showRecommendedRelaysPanel } = useUserPreferences() diff --git a/src/components/Profile/SmartFollowings.tsx b/src/components/Profile/SmartFollowings.tsx index bbb6f21..73b4ad0 100644 --- a/src/components/Profile/SmartFollowings.tsx +++ b/src/components/Profile/SmartFollowings.tsx @@ -1,6 +1,6 @@ import { useFetchFollowings } from '@/hooks' import { toFollowingList } from '@/lib/link' -import { useSmartProfileNavigation } from '@/PageManager' +import { useSmartFollowingListNavigation } from '@/PageManager' import { useFollowList } from '@/providers/FollowListProvider' import { useNostr } from '@/providers/NostrProvider' import { Loader } from 'lucide-react' @@ -11,10 +11,10 @@ export default function SmartFollowings({ pubkey }: { pubkey: string }) { const { pubkey: accountPubkey } = useNostr() const { followings: selfFollowings } = useFollowList() const { followings, isFetching } = useFetchFollowings(pubkey) - const { navigateToProfile } = useSmartProfileNavigation() + const { navigateToFollowingList } = useSmartFollowingListNavigation() const handleClick = () => { - navigateToProfile(toFollowingList(pubkey)) + navigateToFollowingList(toFollowingList(pubkey)) } return ( diff --git a/src/components/Profile/SmartMuteLink.tsx b/src/components/Profile/SmartMuteLink.tsx index 5bcde60..b9334bb 100644 --- a/src/components/Profile/SmartMuteLink.tsx +++ b/src/components/Profile/SmartMuteLink.tsx @@ -1,15 +1,15 @@ import { toMuteList } from '@/lib/link' -import { useSmartSettingsNavigation } from '@/PageManager' +import { useSmartMuteListNavigation } from '@/PageManager' import { useMuteList } from '@/providers/MuteListProvider' import { useTranslation } from 'react-i18next' export default function SmartMuteLink() { const { t } = useTranslation() const { mutePubkeySet } = useMuteList() - const { navigateToSettings } = useSmartSettingsNavigation() + const { navigateToMuteList } = useSmartMuteListNavigation() const handleClick = () => { - navigateToSettings(toMuteList()) + navigateToMuteList(toMuteList()) } return ( diff --git a/src/components/Profile/SmartRelays.tsx b/src/components/Profile/SmartRelays.tsx index 8e79c69..30a384e 100644 --- a/src/components/Profile/SmartRelays.tsx +++ b/src/components/Profile/SmartRelays.tsx @@ -1,19 +1,17 @@ import { useFetchRelayList } from '@/hooks' -import { toOthersRelaySettings, toRelaySettings } from '@/lib/link' -import { useSmartSettingsNavigation } from '@/PageManager' -import { useNostr } from '@/providers/NostrProvider' +import { toOthersRelaySettings } from '@/lib/link' +import { useSmartOthersRelaySettingsNavigation } from '@/PageManager' import { Loader } from 'lucide-react' import { useTranslation } from 'react-i18next' export default function SmartRelays({ pubkey }: { pubkey: string }) { const { t } = useTranslation() - const { pubkey: accountPubkey } = useNostr() const { relayList, isFetching } = useFetchRelayList(pubkey) - const { navigateToSettings } = useSmartSettingsNavigation() + const { navigateToOthersRelaySettings } = useSmartOthersRelaySettingsNavigation() const handleClick = () => { - const url = accountPubkey === pubkey ? toRelaySettings('mailbox') : toOthersRelaySettings(pubkey) - navigateToSettings(url) + // Navigate to the page showing this user's used relays + navigateToOthersRelaySettings(toOthersRelaySettings(pubkey)) } return (