Browse Source

fix profile nav links

imwald
Silberengel 5 months ago
parent
commit
55bef7f887
  1. 67
      src/PageManager.tsx
  2. 6
      src/components/Profile/SmartFollowings.tsx
  3. 6
      src/components/Profile/SmartMuteLink.tsx
  4. 12
      src/components/Profile/SmartRelays.tsx

67
src/PageManager.tsx

@ -12,6 +12,9 @@ import PostSettingsPage from '@/pages/secondary/PostSettingsPage'
import GeneralSettingsPage from '@/pages/secondary/GeneralSettingsPage' import GeneralSettingsPage from '@/pages/secondary/GeneralSettingsPage'
import TranslationPage from '@/pages/secondary/TranslationPage' import TranslationPage from '@/pages/secondary/TranslationPage'
import SecondaryProfilePage from '@/pages/secondary/ProfilePage' 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 { CurrentRelaysProvider } from '@/providers/CurrentRelaysProvider'
import { NotificationProvider } from '@/providers/NotificationProvider' import { NotificationProvider } from '@/providers/NotificationProvider'
import { useUserPreferences } from '@/providers/UserPreferencesProvider' import { useUserPreferences } from '@/providers/UserPreferencesProvider'
@ -208,6 +211,70 @@ export function useSmartHashtagNavigation() {
return { navigateToHashtag } 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(<FollowingListPage id={profileId} index={0} />, '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(<MuteListPage index={0} />, '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(<OthersRelaySettingsPage id={profileId} index={0} />, 'profile')
} else {
// Normal behavior - use secondary navigation
pushSecondary(url)
}
}
return { navigateToOthersRelaySettings }
}
// Custom hook for intelligent settings navigation // Custom hook for intelligent settings navigation
export function useSmartSettingsNavigation() { export function useSmartSettingsNavigation() {
const { showRecommendedRelaysPanel } = useUserPreferences() const { showRecommendedRelaysPanel } = useUserPreferences()

6
src/components/Profile/SmartFollowings.tsx

@ -1,6 +1,6 @@
import { useFetchFollowings } from '@/hooks' import { useFetchFollowings } from '@/hooks'
import { toFollowingList } from '@/lib/link' import { toFollowingList } from '@/lib/link'
import { useSmartProfileNavigation } from '@/PageManager' import { useSmartFollowingListNavigation } from '@/PageManager'
import { useFollowList } from '@/providers/FollowListProvider' import { useFollowList } from '@/providers/FollowListProvider'
import { useNostr } from '@/providers/NostrProvider' import { useNostr } from '@/providers/NostrProvider'
import { Loader } from 'lucide-react' import { Loader } from 'lucide-react'
@ -11,10 +11,10 @@ export default function SmartFollowings({ pubkey }: { pubkey: string }) {
const { pubkey: accountPubkey } = useNostr() const { pubkey: accountPubkey } = useNostr()
const { followings: selfFollowings } = useFollowList() const { followings: selfFollowings } = useFollowList()
const { followings, isFetching } = useFetchFollowings(pubkey) const { followings, isFetching } = useFetchFollowings(pubkey)
const { navigateToProfile } = useSmartProfileNavigation() const { navigateToFollowingList } = useSmartFollowingListNavigation()
const handleClick = () => { const handleClick = () => {
navigateToProfile(toFollowingList(pubkey)) navigateToFollowingList(toFollowingList(pubkey))
} }
return ( return (

6
src/components/Profile/SmartMuteLink.tsx

@ -1,15 +1,15 @@
import { toMuteList } from '@/lib/link' import { toMuteList } from '@/lib/link'
import { useSmartSettingsNavigation } from '@/PageManager' import { useSmartMuteListNavigation } from '@/PageManager'
import { useMuteList } from '@/providers/MuteListProvider' import { useMuteList } from '@/providers/MuteListProvider'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
export default function SmartMuteLink() { export default function SmartMuteLink() {
const { t } = useTranslation() const { t } = useTranslation()
const { mutePubkeySet } = useMuteList() const { mutePubkeySet } = useMuteList()
const { navigateToSettings } = useSmartSettingsNavigation() const { navigateToMuteList } = useSmartMuteListNavigation()
const handleClick = () => { const handleClick = () => {
navigateToSettings(toMuteList()) navigateToMuteList(toMuteList())
} }
return ( return (

12
src/components/Profile/SmartRelays.tsx

@ -1,19 +1,17 @@
import { useFetchRelayList } from '@/hooks' import { useFetchRelayList } from '@/hooks'
import { toOthersRelaySettings, toRelaySettings } from '@/lib/link' import { toOthersRelaySettings } from '@/lib/link'
import { useSmartSettingsNavigation } from '@/PageManager' import { useSmartOthersRelaySettingsNavigation } from '@/PageManager'
import { useNostr } from '@/providers/NostrProvider'
import { Loader } from 'lucide-react' import { Loader } from 'lucide-react'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
export default function SmartRelays({ pubkey }: { pubkey: string }) { export default function SmartRelays({ pubkey }: { pubkey: string }) {
const { t } = useTranslation() const { t } = useTranslation()
const { pubkey: accountPubkey } = useNostr()
const { relayList, isFetching } = useFetchRelayList(pubkey) const { relayList, isFetching } = useFetchRelayList(pubkey)
const { navigateToSettings } = useSmartSettingsNavigation() const { navigateToOthersRelaySettings } = useSmartOthersRelaySettingsNavigation()
const handleClick = () => { const handleClick = () => {
const url = accountPubkey === pubkey ? toRelaySettings('mailbox') : toOthersRelaySettings(pubkey) // Navigate to the page showing this user's used relays
navigateToSettings(url) navigateToOthersRelaySettings(toOthersRelaySettings(pubkey))
} }
return ( return (

Loading…
Cancel
Save