Filter out non-configrable mod authorities from report dialog (#5670)
This commit is contained in:
@@ -169,7 +169,7 @@ export function ModerationScreenInner({
|
|||||||
isLoading: isLabelersLoading,
|
isLoading: isLabelersLoading,
|
||||||
data: labelers,
|
data: labelers,
|
||||||
error: labelersError,
|
error: labelersError,
|
||||||
} = useMyLabelersQuery()
|
} = useMyLabelersQuery({includeNonConfigurable: true})
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
React.useCallback(() => {
|
React.useCallback(() => {
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {
|
import {
|
||||||
DEFAULT_LABEL_SETTINGS,
|
|
||||||
BskyAgent,
|
BskyAgent,
|
||||||
|
DEFAULT_LABEL_SETTINGS,
|
||||||
interpretLabelValueDefinitions,
|
interpretLabelValueDefinitions,
|
||||||
} from '@atproto/api'
|
} from '@atproto/api'
|
||||||
|
|
||||||
import {usePreferencesQuery} from './index'
|
import {isNonConfigurableModerationAuthority} from '#/state/session/additional-moderation-authorities'
|
||||||
import {useLabelersDetailedInfoQuery} from '../labeler'
|
import {useLabelersDetailedInfoQuery} from '../labeler'
|
||||||
|
import {usePreferencesQuery} from './index'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* More strict than our default settings for logged in users.
|
* More strict than our default settings for logged in users.
|
||||||
@@ -16,15 +17,27 @@ export const DEFAULT_LOGGED_OUT_LABEL_PREFERENCES: typeof DEFAULT_LABEL_SETTINGS
|
|||||||
Object.entries(DEFAULT_LABEL_SETTINGS).map(([key, _pref]) => [key, 'hide']),
|
Object.entries(DEFAULT_LABEL_SETTINGS).map(([key, _pref]) => [key, 'hide']),
|
||||||
)
|
)
|
||||||
|
|
||||||
export function useMyLabelersQuery() {
|
export function useMyLabelersQuery({
|
||||||
|
includeNonConfigurable = false,
|
||||||
|
}: {
|
||||||
|
includeNonConfigurable?: boolean
|
||||||
|
} = {}) {
|
||||||
const prefs = usePreferencesQuery()
|
const prefs = usePreferencesQuery()
|
||||||
const dids = Array.from(
|
let dids = Array.from(
|
||||||
new Set(
|
new Set(
|
||||||
BskyAgent.appLabelers.concat(
|
BskyAgent.appLabelers.concat(
|
||||||
prefs.data?.moderationPrefs.labelers.map(l => l.did) || [],
|
prefs.data?.moderationPrefs.labelers.map(l => l.did) || [],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* By default, remove non-configurable moderation authorities
|
||||||
|
*/
|
||||||
|
if (!includeNonConfigurable) {
|
||||||
|
dids = dids.filter(did => !isNonConfigurableModerationAuthority(did))
|
||||||
|
}
|
||||||
|
|
||||||
const labelers = useLabelersDetailedInfoQuery({dids})
|
const labelers = useLabelersDetailedInfoQuery({dids})
|
||||||
const isLoading = prefs.isLoading || labelers.isLoading
|
const isLoading = prefs.isLoading || labelers.isLoading
|
||||||
const error = prefs.error || labelers.error
|
const error = prefs.error || labelers.error
|
||||||
|
|||||||
Reference in New Issue
Block a user