Update profile to pull from labeler definition
This commit is contained in:
+20
-1
@@ -1,5 +1,10 @@
|
||||
import React from 'react'
|
||||
import {ModerationCause, ModerationUI, AppBskyLabelerDefs} from '@atproto/api'
|
||||
import {
|
||||
ModerationCause,
|
||||
ModerationUI,
|
||||
InterprettedLabelValueDefinition,
|
||||
LABELS,
|
||||
} from '@atproto/api'
|
||||
|
||||
import {sanitizeDisplayName} from '#/lib/strings/display-names'
|
||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||
@@ -47,3 +52,17 @@ export function getModerationServiceTitle({
|
||||
? sanitizeDisplayName(displayName)
|
||||
: sanitizeHandle(handle, '@')
|
||||
}
|
||||
|
||||
export function lookupLabelValueDefinition(
|
||||
labelValue: string,
|
||||
customDefs: InterprettedLabelValueDefinition[] | undefined,
|
||||
): InterprettedLabelValueDefinition | undefined {
|
||||
let def
|
||||
if (!labelValue.startsWith('!') && customDefs) {
|
||||
def = customDefs.find(d => d.identifier === labelValue)
|
||||
}
|
||||
if (!def) {
|
||||
def = LABELS[labelValue as keyof typeof LABELS]
|
||||
}
|
||||
return def
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user