diff --git a/src/components/ExternalContentHeader.tsx b/src/components/ExternalContentHeader.tsx index e5eafdb8..94e0e1ea 100644 --- a/src/components/ExternalContentHeader.tsx +++ b/src/components/ExternalContentHeader.tsx @@ -6,6 +6,7 @@ import { Avatar, AvatarImage, AvatarFallback } from '@/components/ui/avatar'; import { Skeleton } from '@/components/ui/skeleton'; import { ExternalFavicon } from '@/components/ExternalFavicon'; import { ExternalReactionButton } from '@/components/ExternalReactionButton'; +import { FollowToggleButton } from '@/components/FollowButton'; import { LinkEmbed } from '@/components/LinkEmbed'; import { ReplyComposeModal } from '@/components/ReplyComposeModal'; import { WikipediaIcon } from '@/components/icons/WikipediaIcon'; @@ -18,6 +19,8 @@ import { useBlueskyPost } from '@/hooks/useBlueskyPost'; import { useBookInfo } from '@/hooks/useBookInfo'; import { useAddrEvent } from '@/hooks/useEvent'; import { useAuthor } from '@/hooks/useAuthor'; +import { useCountryFollows } from '@/hooks/useCountryFollows'; +import { useCurrentUser } from '@/hooks/useCurrentUser'; import { useProfileUrl } from '@/hooks/useProfileUrl'; import { useWeather } from '@/hooks/useWeather'; import { useToast } from '@/hooks/useToast'; @@ -665,6 +668,23 @@ export function CountryContentHeader({ code }: { code: string }) { const info = getCountryInfo(code); const wikiTitle = getWikipediaTitle(code); const { data: wiki, isLoading: wikiLoading } = useWikipediaSummary(wikiTitle); + const { user } = useCurrentUser(); + const { isFollowingCountry, toggleCountryFollow, isPending } = useCountryFollows(); + const { toast } = useToast(); + const isFollowing = info ? isFollowingCountry(code) : false; + + const handleToggleFollow = useCallback(async (event: React.MouseEvent) => { + event.preventDefault(); + event.stopPropagation(); + if (!user || !info || isPending) return; + + try { + await toggleCountryFollow(code); + toast({ title: isFollowing ? 'Country unfollowed' : 'Country followed' }); + } catch { + toast({ title: 'Failed to update country follow', variant: 'destructive' }); + } + }, [user, info, isPending, toggleCountryFollow, code, toast, isFollowing]); if (!info) { return ( @@ -679,7 +699,7 @@ export function CountryContentHeader({ code }: { code: string }) {
- {info.name}{info.subdivisionName ? '' : ` · ${info.subdivision}`} -
- )} - {wiki?.description && ( -- {wiki.description} -
- )} ++ {info.name}{info.subdivisionName ? '' : ` · ${info.subdivision}`} +
+ )} + {wiki?.description && ( ++ {wiki.description} +
+ )} ++ Explore the World tab and follow countries to build your Following feed. +
+