[SDK] Swap moderation to @bsky.app/sdk and move labeler config to Client statics (#11383)
This commit is contained in:
@@ -1,14 +1,12 @@
|
||||
import {createContext, useContext} from 'react'
|
||||
import {
|
||||
type AppBskyLabelerDefs,
|
||||
type InterpretedLabelValueDefinition,
|
||||
} from '@atproto/api'
|
||||
import {type InterpretedLabelValueDefinition} from '@bsky.app/sdk/moderation'
|
||||
|
||||
import {type app} from '#/lexicons'
|
||||
import {useLabelDefinitionsQuery} from '../queries/preferences'
|
||||
|
||||
interface StateContext {
|
||||
labelDefs: Record<string, InterpretedLabelValueDefinition[]>
|
||||
labelers: AppBskyLabelerDefs.LabelerViewDetailed[]
|
||||
labelers: app.bsky.labeler.defs.LabelerViewDetailed[]
|
||||
}
|
||||
|
||||
const stateContext = createContext<StateContext>({
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {createContext, useContext, useMemo} from 'react'
|
||||
import {AtpAgent, type ModerationOpts} from '@atproto/api'
|
||||
import {Client} from '@atproto/lex'
|
||||
import {type ModerationOpts} from '@bsky.app/sdk/moderation'
|
||||
|
||||
import {useHiddenPosts, useLabelDefinitions} from '#/state/preferences'
|
||||
import {DEFAULT_LOGGED_OUT_LABEL_PREFERENCES} from '#/state/queries/preferences/const'
|
||||
@@ -38,16 +39,21 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||
return undefined
|
||||
}
|
||||
return {
|
||||
userDid,
|
||||
/*
|
||||
* `did`/`hiddenPosts` come from persisted storage typed as plain
|
||||
* `string`, so brand them to the SDK's `DidString`/`AtUriString` slots.
|
||||
*/
|
||||
userDid: userDid as ModerationOpts['userDid'],
|
||||
prefs: {
|
||||
...moderationPrefs,
|
||||
labelers: moderationPrefs.labelers.length
|
||||
? moderationPrefs.labelers
|
||||
: AtpAgent.appLabelers.map(did => ({
|
||||
: Client.appLabelers.map(did => ({
|
||||
did,
|
||||
labels: DEFAULT_LOGGED_OUT_LABEL_PREFERENCES,
|
||||
})),
|
||||
hiddenPosts: hiddenPosts || [],
|
||||
hiddenPosts: (hiddenPosts ||
|
||||
[]) as ModerationOpts['prefs']['hiddenPosts'],
|
||||
},
|
||||
labelDefs,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user