From 76f493c27958d5e1008a3a6aa0ca7f959cbe330d Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 4 Sep 2024 18:34:19 -0500 Subject: Ensure profile labels can be appealed separately from account labels (#5154) --- src/lib/moderation.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/lib/moderation.ts') 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]) +} -- cgit 1.4.1