Handle failed pinned feed fetches when rendering list of pinned feeds (#2173)
parent
52ffd6aabb
commit
586c2417a8
|
@ -15,6 +15,7 @@ import {
|
|||
AppBskyUnspeccedGetPopularFeedGenerators,
|
||||
} from '@atproto/api'
|
||||
|
||||
import {logger} from '#/logger'
|
||||
import {router} from '#/routes'
|
||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||
|
@ -289,30 +290,42 @@ export function usePinnedFeedsInfos(): {
|
|||
reqs.push(cached)
|
||||
} else {
|
||||
reqs.push(
|
||||
queryClient.fetchQuery({
|
||||
queryKey: feedSourceInfoQueryKey({uri}),
|
||||
queryFn: async () => {
|
||||
const type = getFeedTypeFromUri(uri)
|
||||
(async () => {
|
||||
// these requests can fail, need to filter those out
|
||||
try {
|
||||
return await queryClient.fetchQuery({
|
||||
queryKey: feedSourceInfoQueryKey({uri}),
|
||||
queryFn: async () => {
|
||||
const type = getFeedTypeFromUri(uri)
|
||||
|
||||
if (type === 'feed') {
|
||||
const res = await getAgent().app.bsky.feed.getFeedGenerator({
|
||||
feed: uri,
|
||||
})
|
||||
return hydrateFeedGenerator(res.data.view)
|
||||
} else {
|
||||
const res = await getAgent().app.bsky.graph.getList({
|
||||
list: uri,
|
||||
limit: 1,
|
||||
})
|
||||
return hydrateList(res.data.list)
|
||||
}
|
||||
},
|
||||
}),
|
||||
if (type === 'feed') {
|
||||
const res =
|
||||
await getAgent().app.bsky.feed.getFeedGenerator({
|
||||
feed: uri,
|
||||
})
|
||||
return hydrateFeedGenerator(res.data.view)
|
||||
} else {
|
||||
const res = await getAgent().app.bsky.graph.getList({
|
||||
list: uri,
|
||||
limit: 1,
|
||||
})
|
||||
return hydrateList(res.data.list)
|
||||
}
|
||||
},
|
||||
})
|
||||
} catch (e) {
|
||||
logger.warn(`usePinnedFeedsInfos: failed to fetch ${uri}`, {
|
||||
error: e,
|
||||
})
|
||||
}
|
||||
})(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
const views = await Promise.all(reqs)
|
||||
const views = (await Promise.all(reqs)).filter(
|
||||
Boolean,
|
||||
) as FeedSourceInfo[]
|
||||
|
||||
setTabs([FOLLOWING_FEED_STUB].concat(views))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue