diff --git a/src/lib/moderation.ts b/src/lib/moderation.ts index 4105c2c2dd..00d8b3fd1c 100644 --- a/src/lib/moderation.ts +++ b/src/lib/moderation.ts @@ -1,11 +1,12 @@ import { - ModerationCause, - ModerationUI, - InterpretedLabelValueDefinition, - LABELS, AppBskyLabelerDefs, BskyAgent, + Did, + InterpretedLabelValueDefinition, + LABELS, + ModerationCause, ModerationOpts, + ModerationUI, } from '@atproto/api' import {sanitizeDisplayName} from '#/lib/strings/display-names' @@ -60,10 +61,9 @@ export function isAppLabeler( | AppBskyLabelerDefs.LabelerView | AppBskyLabelerDefs.LabelerViewDetailed, ): boolean { - if (typeof labeler === 'string') { - return BskyAgent.appLabelers.includes(labeler) - } - return BskyAgent.appLabelers.includes(labeler.creator.did) + const did = typeof labeler === 'string' ? labeler : labeler.creator.did + // assertion here that `did` starts with `did:` + return did.startsWith('did:') && BskyAgent.appLabelers.includes(did as Did) } export function isLabelerSubscribed( diff --git a/src/state/queries/preferences/moderation.ts b/src/state/queries/preferences/moderation.ts index 9cd183e8b1..8cfebe3b2b 100644 --- a/src/state/queries/preferences/moderation.ts +++ b/src/state/queries/preferences/moderation.ts @@ -1,12 +1,13 @@ import React from 'react' import { - DEFAULT_LABEL_SETTINGS, BskyAgent, + DEFAULT_LABEL_SETTINGS, + Did, interpretLabelValueDefinitions, } from '@atproto/api' -import {usePreferencesQuery} from './index' import {useLabelersDetailedInfoQuery} from '../labeler' +import {usePreferencesQuery} from './index' /** * More strict than our default settings for logged in users. @@ -21,7 +22,7 @@ export function useMyLabelersQuery() { const dids = Array.from( new Set( BskyAgent.appLabelers.concat( - prefs.data?.moderationPrefs.labelers.map(l => l.did) || [], + prefs.data?.moderationPrefs.labelers.map(l => l.did as Did) || [], ), ), )