diff options
author | Eric Bailey <git@esb.lol> | 2024-09-04 18:34:19 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-04 18:34:19 -0500 |
commit | 76f493c27958d5e1008a3a6aa0ca7f959cbe330d (patch) | |
tree | e4ab35e4a636c4bef241a656365be9a40b8fce29 /src/lib/moderation.ts | |
parent | 4d97a2aa16083887a9b346d82e3b865e8a000355 (diff) | |
download | voidsky-76f493c27958d5e1008a3a6aa0ca7f959cbe330d.tar.zst |
Ensure profile labels can be appealed separately from account labels (#5154)
Diffstat (limited to 'src/lib/moderation.ts')
-rw-r--r-- | src/lib/moderation.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/lib/moderation.ts b/src/lib/moderation.ts index 3c96deecb..59d88023b 100644 --- a/src/lib/moderation.ts +++ b/src/lib/moderation.ts @@ -1,6 +1,8 @@ +import React from 'react' import { AppBskyLabelerDefs, BskyAgent, + ComAtprotoLabelDefs, InterpretedLabelValueDefinition, LABELS, ModerationCause, @@ -82,3 +84,34 @@ export function isLabelerSubscribed( } return modOpts.prefs.labelers.find(l => l.did === labeler) } + +export type Subject = + | { + uri: string + cid: string + } + | { + did: string + } + +export function useLabelSubject({label}: {label: ComAtprotoLabelDefs.Label}): { + subject: Subject +} { + return React.useMemo(() => { + const {cid, uri} = label + if (cid) { + return { + subject: { + uri, + cid, + }, + } + } else { + return { + subject: { + did: uri, + }, + } + } + }, [label]) +} |