import { Redirect, useLocalSearchParams } from 'expo-router'
import { useActiveProfile } from 'src/state/AuthProvider'

export default function ProfileFeedRedirect() {
  const { id } = useLocalSearchParams<{ id: string }>()
  // Registry-sourced id (single source of truth).
  const { summary } = useActiveProfile()
  const selfId = summary?.userId ?? ''
  if (selfId && id === selfId) {
    return <Redirect href="/(auth)/(tabs)/profile?tab=microblog" />
  }
  return <Redirect href={`/profile/${id}?tab=microblog` as any} />
}
