Ensure profile labels can be appealed separately from account labels (#5154)

This commit is contained in:
Eric Bailey 2024-09-04 18:34:19 -05:00 committed by GitHub
parent 4d97a2aa16
commit 76f493c279
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 45 additions and 22 deletions

View file

@ -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])
}