blob: e24a1144a2df7e66259aee68014d84fecbf05d7a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
import React from 'react'
import {AppBskyLabelerDefs, InterpretedLabelValueDefinition} from '@atproto/api'
import {useLabelDefinitionsQuery} from '../queries/preferences'
interface StateContext {
labelDefs: Record<string, InterpretedLabelValueDefinition[]>
labelers: AppBskyLabelerDefs.LabelerViewDetailed[]
}
const stateContext = React.createContext<StateContext>({
labelDefs: {},
labelers: [],
})
export function Provider({children}: React.PropsWithChildren<{}>) {
const state = useLabelDefinitionsQuery()
return <stateContext.Provider value={state}>{children}</stateContext.Provider>
}
export function useLabelDefinitions() {
return React.useContext(stateContext)
}
|