Better handle feed auth failures (#2060)

* Better handle feed auth failures

* Add comment
zio/stable
Eric Bailey 2023-12-01 11:29:50 -06:00 committed by GitHub
parent edc9ac272c
commit f80bd30ef4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 6 deletions

View File

@ -177,12 +177,13 @@ export function useIsFeedPublicQuery({uri}: {uri: string}) {
}) })
return Boolean(res.data.feed) return Boolean(res.data.feed)
} catch (e: any) { } catch (e: any) {
const msg = e.toString() as string /**
* This should be an `XRPCError`, but I can't safely import from
if (msg.includes('missing jwt')) { * `@atproto/xrpc` due to a depdency on node's `crypto` module.
return false *
} else if (msg.includes('This feed requires being logged-in')) { * @see https://github.com/bluesky-social/atproto/blob/c17971a2d8e424cc7f10c071d97c07c08aa319cf/packages/xrpc/src/client.ts#L126
// e.g. https://github.com/bluesky-social/atproto/blob/99ab1ae55c463e8d5321a1eaad07a175bdd56fea/packages/bsky/src/feed-gen/best-of-follows.ts#L13 */
if (e?.status === 401) {
return false return false
} }