address claude review: getErrorStatus in feed 429 check, fix reportSubject docs
- PostFeedErrorMessage read error?.status directly; only XrpcResponseError carries .status now, so route through getErrorStatus() like the rest of detectKnownError (also drops an oxlint no-unsafe-member-access suppression). - reportSubject.ts docblocks contradicted each other about cid branding; l.CidString is a plain (unbranded) string alias, so the file docstring now says so and the strongRef comments agree. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1683,7 +1683,7 @@
|
||||
"count": 8
|
||||
},
|
||||
"typescript/no-unsafe-member-access": {
|
||||
"count": 9
|
||||
"count": 8
|
||||
}
|
||||
},
|
||||
"src/view/com/util/EmptyState.tsx": {
|
||||
|
||||
@@ -2,9 +2,10 @@ import {type com} from '#/lexicons'
|
||||
|
||||
/**
|
||||
* The `subject` union of the generated `createReport` input body. The lexicon
|
||||
* declares only `com.atproto.admin.defs#repoRef` and `com.atproto.repo.strongRef`
|
||||
* with branded string fields (`did: l.DidString`, `uri: l.AtUriString`,
|
||||
* `cid: l.CidString`).
|
||||
* declares only `com.atproto.admin.defs#repoRef` and `com.atproto.repo.strongRef`.
|
||||
* `did`/`uri` are branded string types (`l.DidString`, `l.AtUriString`); `cid`
|
||||
* is typed `l.CidString`, which is a plain (unbranded) `string` alias, so only
|
||||
* the former two need assertions below.
|
||||
*/
|
||||
type ReportSubject = com.atproto.moderation.createReport.$InputBody['subject']
|
||||
|
||||
@@ -14,7 +15,7 @@ type RepoRefSubject = Extract<
|
||||
{$type: 'com.atproto.admin.defs#repoRef'}
|
||||
>
|
||||
|
||||
/** The strongRef arm of the subject union, carrying the branded `uri`/`cid`. */
|
||||
/** The strongRef arm of the subject union, carrying the branded `uri`. */
|
||||
type StrongRefSubject = Extract<
|
||||
ReportSubject,
|
||||
{$type: 'com.atproto.repo.strongRef'}
|
||||
@@ -33,8 +34,8 @@ export function accountReportSubject(did: string): ReportSubject {
|
||||
|
||||
/**
|
||||
* Branded strongRef subject from plain uri/cid strings. The app holds these as
|
||||
* plain strings; brand `uri` to the lexicon's `uri` slot (`cid` is a plain
|
||||
* string in the generated type, so it needs no assertion).
|
||||
* plain strings; brand `uri` to the lexicon's `uri` slot (`l.CidString` is an
|
||||
* unbranded `string` alias, so `cid` needs no assertion).
|
||||
*/
|
||||
export function recordReportSubject(uri: string, cid: string): ReportSubject {
|
||||
return {
|
||||
|
||||
@@ -9,7 +9,7 @@ import {useNavigation} from '@react-navigation/native'
|
||||
import {usePalette} from '#/lib/hooks/usePalette'
|
||||
import {type NavigationProp} from '#/lib/routes/types'
|
||||
import {cleanError} from '#/lib/strings/errors'
|
||||
import {getErrorName} from '#/lib/xrpc-error'
|
||||
import {getErrorName, getErrorStatus} from '#/lib/xrpc-error'
|
||||
import {logger} from '#/logger'
|
||||
import {type FeedDescriptor} from '#/state/queries/post-feed'
|
||||
import {useRemoveFeedMutation} from '#/state/queries/preferences'
|
||||
@@ -247,7 +247,7 @@ function detectKnownError(
|
||||
}
|
||||
|
||||
// check status codes
|
||||
if (error?.status === 429) {
|
||||
if (getErrorStatus(error) === 429) {
|
||||
return KnownError.FeedTooManyRequests
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user