Better handle feed auth failures (#2060)
* Better handle feed auth failures * Add commentzio/stable
parent
edc9ac272c
commit
f80bd30ef4
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue