Hook up data to settings page

This commit is contained in:
Eric Bailey
2024-02-13 12:40:24 -06:00
parent 6f5058d474
commit 02bbc5e0d5
3 changed files with 69 additions and 44 deletions
+22 -1
View File
@@ -1,4 +1,10 @@
import {ModerationCause, ProfileModeration, PostModeration} from '@atproto/api'
import {
ModerationCause,
ProfileModeration,
PostModeration,
LABEL_GROUPS,
LabelGroupDefinition,
} from '@atproto/api'
export function getProfileModerationCauses(
moderation: ProfileModeration,
@@ -70,3 +76,18 @@ export function getModerationCauseKey(cause: ModerationCause): string {
}
return `${cause.type}:${source}`
}
export function getLabelGroupsFromLabels(labels: string[]) {
const groups: LabelGroupDefinition[] = []
for (const label of labels) {
for (const group in LABEL_GROUPS) {
const def = LABEL_GROUPS[group as LabelGroupDefinition['id']]
if (def.labels.find(l => l.id === label)) {
groups.push(def)
}
}
}
return Array.from(groups)
}