Skip to content

Commit

Permalink
Add additional try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Nov 14, 2023
1 parent 9f3d8e0 commit 2549f9e
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/view/com/auth/onboarding/RecommendedFollows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
})
}
}

Expand Down

0 comments on commit 2549f9e

Please sign in to comment.