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