diff --git a/packages/web/src/components/chat/FriendsPage.tsx b/packages/web/src/components/chat/FriendsPage.tsx index 17381371..68e587c8 100644 --- a/packages/web/src/components/chat/FriendsPage.tsx +++ b/packages/web/src/components/chat/FriendsPage.tsx @@ -18,6 +18,7 @@ import { ActivityCard, hasRichActivity, getActivityAccentClass } from '../ui/Act import { getPrimaryActivity } from '@backspace/shared/src/activities.js'; import { parseFederatedUsername } from '../../utils/identity'; import { Username } from '../ui/Username'; +import { ConfirmDialog } from '../ui/ConfirmDialog'; const statusLabel: Record = { online: 'Online', idle: 'Idle', dnd: 'Do Not Disturb', offline: 'Offline' }; @@ -29,6 +30,7 @@ interface FriendsPageProps { export function FriendsPage({ mobile }: FriendsPageProps) { const [activeTab, setActiveTab] = useState('online'); + const [pendingUnfriend, setPendingUnfriend] = useState<{ id: string; name: string } | null>(null); const navigate = useNavigate(); const addDmChannel = useSpaceStore((s) => s.addDmChannel); @@ -100,7 +102,7 @@ export function FriendsPage({ mobile }: FriendsPageProps) { ) : (
{onlineFriends.map(friend => ( - removeFriend(friend.id)} onDm={() => handleOpenDm(friend.id, friend.homeUserId ?? undefined, friend.homeInstance)} /> + setPendingUnfriend({ id: friend.id, name: friend.displayName ?? parseFederatedUsername(friend.username).baseName })} onDm={() => handleOpenDm(friend.id, friend.homeUserId ?? undefined, friend.homeInstance)} /> ))}
)} @@ -120,7 +122,7 @@ export function FriendsPage({ mobile }: FriendsPageProps) { ) : (
{friends.map(friend => ( - removeFriend(friend.id)} onDm={() => handleOpenDm(friend.id, friend.homeUserId ?? undefined, friend.homeInstance)} /> + setPendingUnfriend({ id: friend.id, name: friend.displayName ?? parseFederatedUsername(friend.username).baseName })} onDm={() => handleOpenDm(friend.id, friend.homeUserId ?? undefined, friend.homeInstance)} /> ))}
)} @@ -353,6 +355,21 @@ export function FriendsPage({ mobile }: FriendsPageProps) { )} {renderTabContent()} + + setPendingUnfriend(null)} + onConfirm={async () => { + if (pendingUnfriend) { + await removeFriend(pendingUnfriend.id); + setPendingUnfriend(null); + } + }} + title="Remove Friend" + description={`Are you sure you want to remove ${pendingUnfriend?.name ?? 'this user'} as a friend? You can always send them a new friend request later.`} + confirmLabel="Remove" + variant="danger" + /> ); }