From 30e276b5a30c8bbe1a4f284f50aa612bf4a3e7ff Mon Sep 17 00:00:00 2001 From: "Builder.io" Date: Tue, 30 Sep 2025 23:10:15 +0000 Subject: [PATCH] Handle follow errors cgen-dcd5c23928014bf2956da27047be0be0 --- client/pages/Feed.tsx | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/client/pages/Feed.tsx b/client/pages/Feed.tsx index b099a203..f8ad4537 100644 --- a/client/pages/Feed.tsx +++ b/client/pages/Feed.tsx @@ -136,13 +136,25 @@ export default function Feed() { const isFollowingAuthor = (id: string) => following.includes(id); const toggleFollow = async (targetId: string) => { - if (!user) return; - if (isFollowingAuthor(targetId)) { - await aethexSocialService.unfollowUser(user.id, targetId); - setFollowing((s) => s.filter((x) => x !== targetId)); - } else { - await aethexSocialService.followUser(user.id, targetId); - setFollowing((s) => Array.from(new Set([...s, targetId]))); + if (!user) { + toast({ description: "Please sign in to manage follows." }); + return; + } + + try { + if (isFollowingAuthor(targetId)) { + await aethexSocialService.unfollowUser(user.id, targetId); + setFollowing((s) => s.filter((x) => x !== targetId)); + } else { + await aethexSocialService.followUser(user.id, targetId); + setFollowing((s) => Array.from(new Set([...s, targetId]))); + } + } catch (error: any) { + toast({ + variant: "destructive", + title: "Action failed", + description: error?.message || "Try again in a moment.", + }); } };