From af210cc45545e6b49ddb2f5203c24f9ab941e705 Mon Sep 17 00:00:00 2001 From: Tsiry Sandratraina Date: Sun, 4 Jan 2026 21:48:17 +0300 Subject: [PATCH] Guard profile.did usage and fix related bugs Add null checks and early returns in Handle to avoid using an undefined profile.did. Add profile.data?.did to effect deps and use "" fallbacks when checking Set membership. Fix useActorCompatibilityQuery type (undefined) and remove unused LabelMedium import. Use empty-string fallback when calling useFollowersInfiniteQuery. --- apps/web/src/components/Handle/Handle.tsx | 19 ++++++++++++++++--- apps/web/src/components/Stats/Stats.tsx | 2 +- apps/web/src/hooks/useProfile.tsx | 2 +- .../src/pages/profile/followers/Followers.tsx | 2 +- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/apps/web/src/components/Handle/Handle.tsx b/apps/web/src/components/Handle/Handle.tsx index 37080eb5..d376e23a 100644 --- a/apps/web/src/components/Handle/Handle.tsx +++ b/apps/web/src/components/Handle/Handle.tsx @@ -50,6 +50,9 @@ function Handle(props: HandleProps) { setIsSignInOpen(true); return; } + if (!profile.data?.did) { + return; + } setFollows((prev) => new Set(prev).add(profile.data?.did)); followAccount(profile.data?.did); }; @@ -59,7 +62,14 @@ function Handle(props: HandleProps) { setIsSignInOpen(true); return; } + if (!profile.data?.did) { + return; + } + setFollows((prev) => { + if (!profile.data?.did) { + return prev; + } const newSet = new Set(prev); newSet.delete(profile.data?.did); return newSet; @@ -73,6 +83,9 @@ function Handle(props: HandleProps) { } setFollows((prev) => { const newSet = new Set(prev); + if (!profile.data?.did) { + return newSet; + } if ( data.followers.some( (follower: { did: string }) => follower.did === currentDid, @@ -84,7 +97,7 @@ function Handle(props: HandleProps) { } return newSet; }); - }, [data, isLoading]); + }, [data, isLoading, currentDid, setFollows, profile.data?.did]); useEffect(() => { if (profile.isLoading || profile.isError) { @@ -169,7 +182,7 @@ function Handle(props: HandleProps) { {(profile.data?.did !== localStorage.getItem("did") || !localStorage.getItem("did")) && (
- {!follows.has(profile.data?.did) && !isLoading && ( + {!follows.has(profile.data?.did || "") && !isLoading && (