From 2549f9e4e7ef4dcce7307238220f5c3abacaf4b4 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 14 Nov 2023 11:19:42 -0600 Subject: [PATCH] Add additional try catch --- .../auth/onboarding/RecommendedFollows.tsx | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/view/com/auth/onboarding/RecommendedFollows.tsx b/src/view/com/auth/onboarding/RecommendedFollows.tsx index 9f195a3666..efe41562e7 100644 --- a/src/view/com/auth/onboarding/RecommendedFollows.tsx +++ b/src/view/com/auth/onboarding/RecommendedFollows.tsx @@ -14,6 +14,7 @@ import {RecommendedFollowsItem} from './RecommendedFollowsItem' import {useSuggestedFollowsQuery} from '#/state/queries/suggested-follows' import {useGetSuggestedFollowersByActor} from '#/state/queries/suggested-follows' import {useModerationOpts} from '#/state/queries/preferences' +import {logger} from '#/logger' type Props = { next: () => void @@ -117,16 +118,22 @@ export const RecommendedFollows = observer(function RecommendedFollowsImpl({ const onFollowStateChange = React.useCallback( async ({following, did}: {following: boolean; did: string}) => { if (following) { - const {suggestions: results} = await getSuggestedFollowsByActor(did) + try { + const {suggestions: results} = await getSuggestedFollowsByActor(did) - if (results.length) { - const deduped = results.filter( - r => !existingDids.current.find(did => did === r.did), - ) - setAdditionalSuggestions(s => ({ - ...s, - [did]: deduped.slice(0, 3), - })) + if (results.length) { + const deduped = results.filter( + r => !existingDids.current.find(did => did === r.did), + ) + setAdditionalSuggestions(s => ({ + ...s, + [did]: deduped.slice(0, 3), + })) + } + } catch (e) { + logger.error('RecommendedFollows: failed to get suggestions', { + error: e, + }) } }