Update to use new sdk updates
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {InterprettedLabelValueDefinition, LabelPreference} from '@atproto/api'
|
||||
import {InterpretedLabelValueDefinition, LabelPreference} from '@atproto/api'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {msg} from '@lingui/macro'
|
||||
|
||||
@@ -18,7 +18,7 @@ export function GlobalModerationLabelPref({
|
||||
labelValueDefinition,
|
||||
disabled,
|
||||
}: {
|
||||
labelValueDefinition: InterprettedLabelValueDefinition
|
||||
labelValueDefinition: InterpretedLabelValueDefinition
|
||||
disabled?: boolean
|
||||
}) {
|
||||
const {_} = useLingui()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import {Pressable, View} from 'react-native'
|
||||
import {InterprettedLabelValueDefinition, LabelPreference} from '@atproto/api'
|
||||
import {InterpretedLabelValueDefinition, LabelPreference} from '@atproto/api'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {msg, Trans} from '@lingui/macro'
|
||||
|
||||
@@ -27,7 +27,7 @@ export function ModerationLabelPref({
|
||||
labelerDid,
|
||||
disabled,
|
||||
}: {
|
||||
labelValueDefinition: InterprettedLabelValueDefinition
|
||||
labelValueDefinition: InterpretedLabelValueDefinition
|
||||
labelerDid: string | undefined
|
||||
disabled?: boolean
|
||||
}) {
|
||||
@@ -39,9 +39,8 @@ export function ModerationLabelPref({
|
||||
const {data: preferences} = usePreferencesQuery()
|
||||
const {mutate, variables} = usePreferencesSetContentLabelMutation()
|
||||
const savedPref = labelerDid
|
||||
? preferences?.moderationPrefs.mods.find(m => m.did === labelerDid)?.labels[
|
||||
identifier
|
||||
]
|
||||
? preferences?.moderationPrefs.labelers.find(l => l.did === labelerDid)
|
||||
?.labels[identifier]
|
||||
: preferences?.moderationPrefs.labels[identifier]
|
||||
const pref = variables?.visibility ?? savedPref ?? 'warn'
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {
|
||||
ModerationCause,
|
||||
ModerationUI,
|
||||
InterprettedLabelValueDefinition,
|
||||
InterpretedLabelValueDefinition,
|
||||
LABELS,
|
||||
} from '@atproto/api'
|
||||
|
||||
@@ -39,8 +39,8 @@ export function getModerationServiceTitle({
|
||||
|
||||
export function lookupLabelValueDefinition(
|
||||
labelValue: string,
|
||||
customDefs: InterprettedLabelValueDefinition[] | undefined,
|
||||
): InterprettedLabelValueDefinition | undefined {
|
||||
customDefs: InterpretedLabelValueDefinition[] | undefined,
|
||||
): InterpretedLabelValueDefinition | undefined {
|
||||
let def
|
||||
if (!labelValue.startsWith('!') && customDefs) {
|
||||
def = customDefs.find(d => d.identifier === labelValue)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import {InterprettedLabelValueDefinition, LabelPreference} from '@atproto/api'
|
||||
import {InterpretedLabelValueDefinition, LabelPreference} from '@atproto/api'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {msg} from '@lingui/macro'
|
||||
|
||||
export function useLabelBehaviorDescription(
|
||||
labelValueDef: InterprettedLabelValueDefinition,
|
||||
labelValueDef: InterpretedLabelValueDefinition,
|
||||
pref: LabelPreference,
|
||||
) {
|
||||
const {_} = useLingui()
|
||||
@@ -39,7 +39,7 @@ export function useLabelBehaviorDescription(
|
||||
}
|
||||
|
||||
export function useLabelLongBehaviorDescription(
|
||||
labelValueDef: InterprettedLabelValueDefinition,
|
||||
labelValueDef: InterpretedLabelValueDefinition,
|
||||
pref: LabelPreference,
|
||||
) {
|
||||
const {_} = useLingui()
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
AppBskyLabelerDefs,
|
||||
LABELS,
|
||||
interpretLabelValueDefinition,
|
||||
InterprettedLabelValueDefinition,
|
||||
InterpretedLabelValueDefinition,
|
||||
} from '@atproto/api'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import * as bcp47Match from 'bcp-47-match'
|
||||
@@ -16,7 +16,7 @@ import {useLabelDefinitions} from '#/state/queries/preferences'
|
||||
|
||||
export interface LabelInfo {
|
||||
label: ComAtprotoLabelDefs.Label
|
||||
def: InterprettedLabelValueDefinition
|
||||
def: InterpretedLabelValueDefinition
|
||||
strings: ComAtprotoLabelDefs.LabelValueDefinitionStrings
|
||||
labeler: AppBskyLabelerDefs.LabelerViewDetailed | undefined
|
||||
}
|
||||
@@ -35,9 +35,9 @@ export function useLabelInfo(label: ComAtprotoLabelDefs.Label): LabelInfo {
|
||||
}
|
||||
|
||||
export function getDefinition(
|
||||
labelDefs: Record<string, InterprettedLabelValueDefinition[]>,
|
||||
labelDefs: Record<string, InterpretedLabelValueDefinition[]>,
|
||||
label: ComAtprotoLabelDefs.Label,
|
||||
): InterprettedLabelValueDefinition {
|
||||
): InterpretedLabelValueDefinition {
|
||||
// check local definitions
|
||||
const customDef =
|
||||
!label.val.startsWith('!') &&
|
||||
@@ -60,6 +60,7 @@ export function getDefinition(
|
||||
identifier: label.val,
|
||||
severity: 'none',
|
||||
blurs: 'none',
|
||||
defaultSetting: 'ignore',
|
||||
locales: [],
|
||||
},
|
||||
label.src,
|
||||
@@ -69,7 +70,7 @@ export function getDefinition(
|
||||
export function getLabelStrings(
|
||||
locale: string,
|
||||
globalLabelStrings: GlobalLabelStrings,
|
||||
def: InterprettedLabelValueDefinition,
|
||||
def: InterpretedLabelValueDefinition,
|
||||
): ComAtprotoLabelDefs.LabelValueDefinitionStrings {
|
||||
if (!def.definedBy) {
|
||||
// global definition, look up strings
|
||||
|
||||
@@ -86,7 +86,9 @@ export function ModerationScreen(
|
||||
data: labelers,
|
||||
error: labelersError,
|
||||
} = useLabelersDetailedInfoQuery({
|
||||
dids: preferences ? preferences.moderationPrefs.mods.map(m => m.did) : [],
|
||||
dids: preferences
|
||||
? preferences.moderationPrefs.labelers.map(l => l.did)
|
||||
: [],
|
||||
})
|
||||
const {gtMobile} = useBreakpoints()
|
||||
const {height} = useSafeAreaFrame()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React from 'react'
|
||||
import {View} from 'react-native'
|
||||
import {LabelPreference, InterprettedLabelValueDefinition} from '@atproto/api'
|
||||
import {LabelPreference, InterpretedLabelValueDefinition} from '@atproto/api'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {msg} from '@lingui/macro'
|
||||
import Animated, {Easing, Layout, FadeIn} from 'react-native-reanimated'
|
||||
@@ -18,7 +18,7 @@ export function ModerationOption({
|
||||
labelValueDefinition,
|
||||
isMounted,
|
||||
}: {
|
||||
labelValueDefinition: InterprettedLabelValueDefinition
|
||||
labelValueDefinition: InterpretedLabelValueDefinition
|
||||
isMounted: React.MutableRefObject<boolean>
|
||||
}) {
|
||||
const {_} = useLingui()
|
||||
|
||||
@@ -75,10 +75,10 @@ let ProfileHeaderLabeler = ({
|
||||
useLabelerSubscriptionMutation()
|
||||
const isSubscribed =
|
||||
variables?.subscribe ??
|
||||
preferences?.moderationPrefs.mods.find(mod => mod.did === profile.did)
|
||||
preferences?.moderationPrefs.labelers.find(l => l.did === profile.did)
|
||||
const canSubscribe =
|
||||
isSubscribed ||
|
||||
(preferences ? preferences?.moderationPrefs.mods.length < 10 : false)
|
||||
(preferences ? preferences?.moderationPrefs.labelers.length < 10 : false)
|
||||
const {mutateAsync: likeMod, isPending: isLikePending} = useLikeMutation()
|
||||
const {mutateAsync: unlikeMod, isPending: isUnlikePending} =
|
||||
useUnlikeMutation()
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
AppBskyLabelerDefs,
|
||||
ModerationOpts,
|
||||
interpretLabelValueDefinitions,
|
||||
InterprettedLabelValueDefinition,
|
||||
InterpretedLabelValueDefinition,
|
||||
} from '@atproto/api'
|
||||
import {Trans, msg} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
@@ -126,8 +126,8 @@ export function ProfileLabelsSectionInner({
|
||||
})
|
||||
|
||||
const {labelValues} = labelerInfo.policies
|
||||
const isSubscribed = moderationOpts.prefs.mods.find(
|
||||
mod => mod.did === labelerInfo.creator.did,
|
||||
const isSubscribed = moderationOpts.prefs.labelers.find(
|
||||
l => l.did === labelerInfo.creator.did,
|
||||
)
|
||||
const labelDefs = React.useMemo(() => {
|
||||
const customDefs = interpretLabelValueDefinitions(labelerInfo)
|
||||
@@ -135,7 +135,7 @@ export function ProfileLabelsSectionInner({
|
||||
.map(val => lookupLabelValueDefinition(val, customDefs))
|
||||
.filter(
|
||||
def => def && def?.configurable,
|
||||
) as InterprettedLabelValueDefinition[]
|
||||
) as InterpretedLabelValueDefinition[]
|
||||
}, [labelerInfo, labelValues])
|
||||
|
||||
return (
|
||||
|
||||
@@ -73,9 +73,9 @@ export function useLabelerSubscriptionMutation() {
|
||||
}).parse({did, subscribe})
|
||||
|
||||
if (subscribe) {
|
||||
await getAgent().addModService(did)
|
||||
await getAgent().addLabeler(did)
|
||||
} else {
|
||||
await getAgent().removeModService(did)
|
||||
await getAgent().removeLabeler(did)
|
||||
}
|
||||
},
|
||||
onSuccess() {
|
||||
|
||||
@@ -37,7 +37,7 @@ export const DEFAULT_LOGGED_OUT_PREFERENCES: UsePreferencesQueryResponse = {
|
||||
moderationPrefs: {
|
||||
adultContentEnabled: false,
|
||||
labels: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES,
|
||||
mods: [],
|
||||
labelers: [],
|
||||
},
|
||||
feedViewPrefs: DEFAULT_HOME_FEED_PREFS,
|
||||
threadViewPrefs: DEFAULT_THREAD_VIEW_PREFS,
|
||||
|
||||
@@ -17,7 +17,7 @@ export const DEFAULT_LOGGED_OUT_LABEL_PREFERENCES: typeof DEFAULT_LABEL_SETTINGS
|
||||
|
||||
export function useMyLabelers() {
|
||||
const prefs = usePreferencesQuery()
|
||||
const dids = prefs.data?.moderationPrefs.mods.map(m => m.did) || []
|
||||
const dids = prefs.data?.moderationPrefs.labelers.map(l => l.did) || []
|
||||
if (!dids.includes(BSKY_LABELER_DID)) {
|
||||
dids.push(BSKY_LABELER_DID)
|
||||
}
|
||||
|
||||
@@ -64,6 +64,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
|
||||
identifier: 'custom',
|
||||
blurs: 'content',
|
||||
severity: 'alert',
|
||||
defaultSetting: 'warn',
|
||||
locales: [
|
||||
{
|
||||
lang: 'en',
|
||||
@@ -235,7 +236,7 @@ export const DebugModScreen = ({}: NativeStackScreenProps<
|
||||
labels: {
|
||||
[label[0]]: visibility[0] as LabelPreference,
|
||||
},
|
||||
mods: [
|
||||
labelers: [
|
||||
{
|
||||
did: 'did:plc:fake-labeler',
|
||||
labels: {[label[0]]: visibility[0] as LabelPreference},
|
||||
|
||||
Reference in New Issue
Block a user