Add displayName to contexts (#8814)
This commit is contained in:
@@ -1,7 +1,8 @@
|
|||||||
import React, {ReactNode} from 'react'
|
import React, {type ReactNode} from 'react'
|
||||||
import {View, ScrollView, Modal, FlatList, TextInput} from 'react-native'
|
import {FlatList, Modal, ScrollView, TextInput, View} from 'react-native'
|
||||||
|
|
||||||
const BottomSheetModalContext = React.createContext(null)
|
const BottomSheetModalContext = React.createContext(null)
|
||||||
|
BottomSheetModalContext.displayName = 'BottomSheetModalContext'
|
||||||
|
|
||||||
const BottomSheetModalProvider = (props: any) => {
|
const BottomSheetModalProvider = (props: any) => {
|
||||||
return <BottomSheetModalContext.Provider {...props} value={{}} />
|
return <BottomSheetModalContext.Provider {...props} value={{}} />
|
||||||
@@ -47,13 +48,13 @@ export {useBottomSheetInternal}
|
|||||||
export {useBottomSheetDynamicSnapPoints}
|
export {useBottomSheetDynamicSnapPoints}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
BottomSheetModalProvider,
|
|
||||||
BottomSheetBackdrop,
|
BottomSheetBackdrop,
|
||||||
|
BottomSheetFlatList,
|
||||||
|
BottomSheetFooter,
|
||||||
BottomSheetHandle,
|
BottomSheetHandle,
|
||||||
BottomSheetModal,
|
BottomSheetModal,
|
||||||
BottomSheetFooter,
|
BottomSheetModalProvider,
|
||||||
BottomSheetScrollView,
|
BottomSheetScrollView,
|
||||||
BottomSheetFlatList,
|
|
||||||
BottomSheetTextInput,
|
BottomSheetTextInput,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import {createPortalGroup_INTERNAL} from './lib/Portal'
|
|||||||
type PortalContext = React.ElementType<{children: React.ReactNode}>
|
type PortalContext = React.ElementType<{children: React.ReactNode}>
|
||||||
|
|
||||||
export const Context = React.createContext({} as PortalContext)
|
export const Context = React.createContext({} as PortalContext)
|
||||||
|
Context.displayName = 'BottomSheetPortalContext'
|
||||||
|
|
||||||
export const useBottomSheetPortal_INTERNAL = () => React.useContext(Context)
|
export const useBottomSheetPortal_INTERNAL = () => React.useContext(Context)
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ export function createPortalGroup_INTERNAL() {
|
|||||||
append: () => {},
|
append: () => {},
|
||||||
remove: () => {},
|
remove: () => {},
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'BottomSheetPortalContext'
|
||||||
|
|
||||||
function Provider(props: React.PropsWithChildren<{}>) {
|
function Provider(props: React.PropsWithChildren<{}>) {
|
||||||
const map = React.useRef<ComponentMap>({})
|
const map = React.useRef<ComponentMap>({})
|
||||||
|
|||||||
+3
-2
@@ -8,9 +8,9 @@ import {
|
|||||||
setFontScale as persistFontScale,
|
setFontScale as persistFontScale,
|
||||||
} from '#/alf/fonts'
|
} from '#/alf/fonts'
|
||||||
import {createThemes, defaultTheme} from '#/alf/themes'
|
import {createThemes, defaultTheme} from '#/alf/themes'
|
||||||
import {Theme, ThemeName} from '#/alf/types'
|
import {type Theme, type ThemeName} from '#/alf/types'
|
||||||
import {BLUE_HUE, GREEN_HUE, RED_HUE} from '#/alf/util/colorGeneration'
|
import {BLUE_HUE, GREEN_HUE, RED_HUE} from '#/alf/util/colorGeneration'
|
||||||
import {Device} from '#/storage'
|
import {type Device} from '#/storage'
|
||||||
|
|
||||||
export {atoms} from '#/alf/atoms'
|
export {atoms} from '#/alf/atoms'
|
||||||
export * from '#/alf/breakpoints'
|
export * from '#/alf/breakpoints'
|
||||||
@@ -61,6 +61,7 @@ export const Context = React.createContext<Alf>({
|
|||||||
},
|
},
|
||||||
flags: {},
|
flags: {},
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'AlfContext'
|
||||||
|
|
||||||
export function ThemeProvider({
|
export function ThemeProvider({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ type Context = {
|
|||||||
const Context = createContext<Context>({
|
const Context = createContext<Context>({
|
||||||
type: 'info',
|
type: 'info',
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'AdmonitionContext'
|
||||||
|
|
||||||
export function Icon() {
|
export function Icon() {
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
|||||||
@@ -109,6 +109,7 @@ const Context = React.createContext<VariantProps & ButtonState>({
|
|||||||
pressed: false,
|
pressed: false,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'ButtonContext'
|
||||||
|
|
||||||
export function useButtonContext() {
|
export function useButtonContext() {
|
||||||
return React.useContext(Context)
|
return React.useContext(Context)
|
||||||
|
|||||||
@@ -7,10 +7,13 @@ import {
|
|||||||
} from '#/components/ContextMenu/types'
|
} from '#/components/ContextMenu/types'
|
||||||
|
|
||||||
export const Context = React.createContext<ContextType | null>(null)
|
export const Context = React.createContext<ContextType | null>(null)
|
||||||
|
Context.displayName = 'ContextMenuContext'
|
||||||
|
|
||||||
export const MenuContext = React.createContext<MenuContextType | null>(null)
|
export const MenuContext = React.createContext<MenuContextType | null>(null)
|
||||||
|
MenuContext.displayName = 'ContextMenuMenuContext'
|
||||||
|
|
||||||
export const ItemContext = React.createContext<ItemContextType | null>(null)
|
export const ItemContext = React.createContext<ItemContextType | null>(null)
|
||||||
|
ItemContext.displayName = 'ContextMenuItemContext'
|
||||||
|
|
||||||
export function useContextMenuContext() {
|
export function useContextMenuContext() {
|
||||||
const context = React.useContext(Context)
|
const context = React.useContext(Context)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ export const Context = createContext<DialogContextProps>({
|
|||||||
setDisableDrag: () => {},
|
setDisableDrag: () => {},
|
||||||
isWithinDialog: false,
|
isWithinDialog: false,
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'DialogContext'
|
||||||
|
|
||||||
export function useDialogContext() {
|
export function useDialogContext() {
|
||||||
return useContext(Context)
|
return useContext(Context)
|
||||||
|
|||||||
@@ -1,11 +1,12 @@
|
|||||||
import {createContext, useContext, useMemo} from 'react'
|
import {createContext, useContext, useMemo} from 'react'
|
||||||
import {View} from 'react-native'
|
import {View} from 'react-native'
|
||||||
|
|
||||||
import {atoms as a, ViewStyleProp} from '#/alf'
|
import {atoms as a, type ViewStyleProp} from '#/alf'
|
||||||
|
|
||||||
const Context = createContext({
|
const Context = createContext({
|
||||||
gap: 0,
|
gap: 0,
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'GridContext'
|
||||||
|
|
||||||
export function Row({
|
export function Row({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ export function Outer({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const AlignmentContext = createContext<'platform' | 'left'>('platform')
|
const AlignmentContext = createContext<'platform' | 'left'>('platform')
|
||||||
|
AlignmentContext.displayName = 'AlignmentContext'
|
||||||
|
|
||||||
export function Content({
|
export function Content({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -3,3 +3,4 @@ import React from 'react'
|
|||||||
export const ScrollbarOffsetContext = React.createContext({
|
export const ScrollbarOffsetContext = React.createContext({
|
||||||
isWithinOffsetView: false,
|
isWithinOffsetView: false,
|
||||||
})
|
})
|
||||||
|
ScrollbarOffsetContext.displayName = 'ScrollbarOffsetContext'
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ import React from 'react'
|
|||||||
import {type ContextType, type ItemContextType} from '#/components/Menu/types'
|
import {type ContextType, type ItemContextType} from '#/components/Menu/types'
|
||||||
|
|
||||||
export const Context = React.createContext<ContextType | null>(null)
|
export const Context = React.createContext<ContextType | null>(null)
|
||||||
|
Context.displayName = 'MenuContext'
|
||||||
|
|
||||||
export const ItemContext = React.createContext<ItemContextType | null>(null)
|
export const ItemContext = React.createContext<ItemContextType | null>(null)
|
||||||
|
ItemContext.displayName = 'MenuItemContext'
|
||||||
|
|
||||||
export function useMenuContext() {
|
export function useMenuContext() {
|
||||||
const context = React.useContext(Context)
|
const context = React.useContext(Context)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ const Context = createContext<{
|
|||||||
*/
|
*/
|
||||||
setIsReadyToShowOverlay: () => {},
|
setIsReadyToShowOverlay: () => {},
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'PolicyUpdateOverlayContext'
|
||||||
|
|
||||||
export function usePolicyUpdateContext() {
|
export function usePolicyUpdateContext() {
|
||||||
const context = useContext(Context)
|
const context = useContext(Context)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ export function createPortalGroup() {
|
|||||||
append: () => {},
|
append: () => {},
|
||||||
remove: () => {},
|
remove: () => {},
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'PortalContext'
|
||||||
|
|
||||||
function Provider(props: React.PropsWithChildren<{}>) {
|
function Provider(props: React.PropsWithChildren<{}>) {
|
||||||
const map = useRef<ComponentMap>({})
|
const map = useRef<ComponentMap>({})
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ const Context = React.createContext<{
|
|||||||
setActiveView: (viewId: string) => void
|
setActiveView: (viewId: string) => void
|
||||||
sendViewPosition: (viewId: string, y: number) => void
|
sendViewPosition: (viewId: string, y: number) => void
|
||||||
} | null>(null)
|
} | null>(null)
|
||||||
|
Context.displayName = 'ActiveVideoWebContext'
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
if (!isWeb) {
|
if (!isWeb) {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const Context = React.createContext<{
|
|||||||
volume: number
|
volume: number
|
||||||
setVolume: React.Dispatch<React.SetStateAction<number>>
|
setVolume: React.Dispatch<React.SetStateAction<number>>
|
||||||
} | null>(null)
|
} | null>(null)
|
||||||
|
Context.displayName = 'VideoVolumeContext'
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
const [muted, setMuted] = React.useState(true)
|
const [muted, setMuted] = React.useState(true)
|
||||||
|
|||||||
@@ -125,6 +125,7 @@ export function VideoEmbed({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const NearScreenContext = createContext(false)
|
const NearScreenContext = createContext(false)
|
||||||
|
NearScreenContext.displayName = 'VideoNearScreenContext'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Renders a 100vh tall div and watches it with an IntersectionObserver to
|
* Renders a 100vh tall div and watches it with an IntersectionObserver to
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ const PostControlContext = createContext<{
|
|||||||
active?: boolean
|
active?: boolean
|
||||||
color?: {color: string}
|
color?: {color: string}
|
||||||
}>({})
|
}>({})
|
||||||
|
PostControlContext.displayName = 'PostControlContext'
|
||||||
|
|
||||||
// Base button style, which the the other ones extend
|
// Base button style, which the the other ones extend
|
||||||
export function PostControlButton({
|
export function PostControlButton({
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ const Context = React.createContext<{
|
|||||||
titleId: '',
|
titleId: '',
|
||||||
descriptionId: '',
|
descriptionId: '',
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'PromptContext'
|
||||||
|
|
||||||
export function Outer({
|
export function Outer({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -34,10 +34,12 @@ type ContextType = {
|
|||||||
} & Pick<RootProps, 'value' | 'onValueChange' | 'disabled'>
|
} & Pick<RootProps, 'value' | 'onValueChange' | 'disabled'>
|
||||||
|
|
||||||
const Context = createContext<ContextType | null>(null)
|
const Context = createContext<ContextType | null>(null)
|
||||||
|
Context.displayName = 'SelectContext'
|
||||||
|
|
||||||
const ValueTextContext = createContext<
|
const ValueTextContext = createContext<
|
||||||
[any, React.Dispatch<React.SetStateAction<any>>]
|
[any, React.Dispatch<React.SetStateAction<any>>]
|
||||||
>([undefined, () => {}])
|
>([undefined, () => {}])
|
||||||
|
ValueTextContext.displayName = 'ValueTextContext'
|
||||||
|
|
||||||
function useSelectContext() {
|
function useSelectContext() {
|
||||||
const ctx = useContext(Context)
|
const ctx = useContext(Context)
|
||||||
@@ -229,6 +231,7 @@ const ItemContext = createContext<{
|
|||||||
focused: false,
|
focused: false,
|
||||||
pressed: false,
|
pressed: false,
|
||||||
})
|
})
|
||||||
|
ItemContext.displayName = 'SelectItemContext'
|
||||||
|
|
||||||
export function useItemContext() {
|
export function useItemContext() {
|
||||||
return useContext(ItemContext)
|
return useContext(ItemContext)
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import {
|
|||||||
} from './types'
|
} from './types'
|
||||||
|
|
||||||
const SelectedValueContext = createContext<string | undefined | null>(null)
|
const SelectedValueContext = createContext<string | undefined | null>(null)
|
||||||
|
SelectedValueContext.displayName = 'SelectSelectedValueContext'
|
||||||
|
|
||||||
export function Root(props: RootProps) {
|
export function Root(props: RootProps) {
|
||||||
return (
|
return (
|
||||||
@@ -219,6 +220,7 @@ const ItemContext = createContext<{
|
|||||||
pressed: false,
|
pressed: false,
|
||||||
selected: false,
|
selected: false,
|
||||||
})
|
})
|
||||||
|
ItemContext.displayName = 'SelectItemContext'
|
||||||
|
|
||||||
export function useItemContext() {
|
export function useItemContext() {
|
||||||
return useContext(ItemContext)
|
return useContext(ItemContext)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ export const ICONS = {
|
|||||||
const Context = createContext<ContextType>({
|
const Context = createContext<ContextType>({
|
||||||
type: 'default',
|
type: 'default',
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'ToastContext'
|
||||||
|
|
||||||
export function Toast({
|
export function Toast({
|
||||||
type,
|
type,
|
||||||
|
|||||||
@@ -53,12 +53,14 @@ const TooltipContext = createContext<TooltipContextType>({
|
|||||||
visible: false,
|
visible: false,
|
||||||
onVisibleChange: () => {},
|
onVisibleChange: () => {},
|
||||||
})
|
})
|
||||||
|
TooltipContext.displayName = 'TooltipContext'
|
||||||
|
|
||||||
const TargetContext = createContext<TargetContextType>({
|
const TargetContext = createContext<TargetContextType>({
|
||||||
targetMeasurements: undefined,
|
targetMeasurements: undefined,
|
||||||
setTargetMeasurements: () => {},
|
setTargetMeasurements: () => {},
|
||||||
shouldMeasure: false,
|
shouldMeasure: false,
|
||||||
})
|
})
|
||||||
|
TargetContext.displayName = 'TargetContext'
|
||||||
|
|
||||||
export function Outer({
|
export function Outer({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const TooltipContext = createContext<TooltipContextType>({
|
|||||||
position: 'bottom',
|
position: 'bottom',
|
||||||
onVisibleChange: () => {},
|
onVisibleChange: () => {},
|
||||||
})
|
})
|
||||||
|
TooltipContext.displayName = 'TooltipContext'
|
||||||
|
|
||||||
export function Outer({
|
export function Outer({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ type ControlsContext = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const ControlsContext = createContext<ControlsContext | null>(null)
|
const ControlsContext = createContext<ControlsContext | null>(null)
|
||||||
|
ControlsContext.displayName = 'GlobalDialogControlsContext'
|
||||||
|
|
||||||
export function useGlobalDialogsControlContext() {
|
export function useGlobalDialogsControlContext() {
|
||||||
const ctx = useContext(ControlsContext)
|
const ctx = useContext(ControlsContext)
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ const Context = React.createContext<Context>({
|
|||||||
activeNux: undefined,
|
activeNux: undefined,
|
||||||
dismissActiveNux: () => {},
|
dismissActiveNux: () => {},
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'NuxDialogContext'
|
||||||
|
|
||||||
export function useNuxDialogContext() {
|
export function useNuxDialogContext() {
|
||||||
return React.useContext(Context)
|
return React.useContext(Context)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
const MessageContext = React.createContext(false)
|
const MessageContext = React.createContext(false)
|
||||||
|
MessageContext.displayName = 'MessageContext'
|
||||||
|
|
||||||
export function MessageContextProvider({
|
export function MessageContextProvider({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ const Context = createContext<{
|
|||||||
onFocus: () => {},
|
onFocus: () => {},
|
||||||
onBlur: () => {},
|
onBlur: () => {},
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'TextFieldContext'
|
||||||
|
|
||||||
export type RootProps = React.PropsWithChildren<{isInvalid?: boolean}>
|
export type RootProps = React.PropsWithChildren<{isInvalid?: boolean}>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {Pressable, View, ViewStyle} from 'react-native'
|
import {Pressable, View, type ViewStyle} from 'react-native'
|
||||||
import Animated, {LinearTransition} from 'react-native-reanimated'
|
import Animated, {LinearTransition} from 'react-native-reanimated'
|
||||||
|
|
||||||
import {HITSLOP_10} from '#/lib/constants'
|
import {HITSLOP_10} from '#/lib/constants'
|
||||||
@@ -8,9 +8,9 @@ import {
|
|||||||
atoms as a,
|
atoms as a,
|
||||||
flatten,
|
flatten,
|
||||||
native,
|
native,
|
||||||
TextStyleProp,
|
type TextStyleProp,
|
||||||
useTheme,
|
useTheme,
|
||||||
ViewStyleProp,
|
type ViewStyleProp,
|
||||||
} from '#/alf'
|
} from '#/alf'
|
||||||
import {useInteractionState} from '#/components/hooks/useInteractionState'
|
import {useInteractionState} from '#/components/hooks/useInteractionState'
|
||||||
import {CheckThick_Stroke2_Corner0_Rounded as Checkmark} from '#/components/icons/Check'
|
import {CheckThick_Stroke2_Corner0_Rounded as Checkmark} from '#/components/icons/Check'
|
||||||
@@ -35,6 +35,7 @@ const ItemContext = React.createContext<ItemState>({
|
|||||||
pressed: false,
|
pressed: false,
|
||||||
focused: false,
|
focused: false,
|
||||||
})
|
})
|
||||||
|
ItemContext.displayName = 'ToggleItemContext'
|
||||||
|
|
||||||
const GroupContext = React.createContext<{
|
const GroupContext = React.createContext<{
|
||||||
values: string[]
|
values: string[]
|
||||||
@@ -49,6 +50,7 @@ const GroupContext = React.createContext<{
|
|||||||
maxSelectionsReached: false,
|
maxSelectionsReached: false,
|
||||||
setFieldValue: () => {},
|
setFieldValue: () => {},
|
||||||
})
|
})
|
||||||
|
GroupContext.displayName = 'ToggleGroupContext'
|
||||||
|
|
||||||
export type GroupProps = React.PropsWithChildren<{
|
export type GroupProps = React.PropsWithChildren<{
|
||||||
type?: 'radio' | 'checkbox'
|
type?: 'radio' | 'checkbox'
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import * as Dialog from '#/components/Dialog'
|
import * as Dialog from '#/components/Dialog'
|
||||||
import {DialogControlProps} from '#/components/Dialog'
|
import {type DialogControlProps} from '#/components/Dialog'
|
||||||
import {VerifyEmailIntentDialog} from '#/components/intents/VerifyEmailIntentDialog'
|
import {VerifyEmailIntentDialog} from '#/components/intents/VerifyEmailIntentDialog'
|
||||||
|
|
||||||
interface Context {
|
interface Context {
|
||||||
@@ -11,6 +11,7 @@ interface Context {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Context = React.createContext({} as Context)
|
const Context = React.createContext({} as Context)
|
||||||
|
Context.displayName = 'IntentDialogsContext'
|
||||||
export const useIntentDialogs = () => React.useContext(Context)
|
export const useIntentDialogs = () => React.useContext(Context)
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {ModerationUI} from '@atproto/api'
|
import {type ModerationUI} from '@atproto/api'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ModerationCauseDescription,
|
type ModerationCauseDescription,
|
||||||
useModerationCauseDescription,
|
useModerationCauseDescription,
|
||||||
} from '#/lib/moderation/useModerationCauseDescription'
|
} from '#/lib/moderation/useModerationCauseDescription'
|
||||||
import {
|
import {
|
||||||
@@ -22,6 +22,7 @@ type Context = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Context = React.createContext<Context>({} as Context)
|
const Context = React.createContext<Context>({} as Context)
|
||||||
|
Context.displayName = 'HiderContext'
|
||||||
|
|
||||||
export const useHider = () => React.useContext(Context)
|
export const useHider = () => React.useContext(Context)
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, {createContext, useContext, useMemo} from 'react'
|
import {createContext, useContext, useMemo} from 'react'
|
||||||
import {ScrollHandlers} from 'react-native-reanimated'
|
import {type ScrollHandlers} from 'react-native-reanimated'
|
||||||
|
|
||||||
const ScrollContext = createContext<ScrollHandlers<any>>({
|
const ScrollContext = createContext<ScrollHandlers<any>>({
|
||||||
onBeginDrag: undefined,
|
onBeginDrag: undefined,
|
||||||
@@ -7,6 +7,7 @@ const ScrollContext = createContext<ScrollHandlers<any>>({
|
|||||||
onScroll: undefined,
|
onScroll: undefined,
|
||||||
onMomentumEnd: undefined,
|
onMomentumEnd: undefined,
|
||||||
})
|
})
|
||||||
|
ScrollContext.displayName = 'ScrollContext'
|
||||||
|
|
||||||
export function useScrollHandlers(): ScrollHandlers<any> {
|
export function useScrollHandlers(): ScrollHandlers<any> {
|
||||||
return useContext(ScrollContext)
|
return useContext(ScrollContext)
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ export interface ThemeProviderProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ThemeContext = createContext<Theme>(defaultTheme)
|
export const ThemeContext = createContext<Theme>(defaultTheme)
|
||||||
|
ThemeContext.displayName = 'ThemeContext'
|
||||||
|
|
||||||
export const useTheme = () => useContext(ThemeContext)
|
export const useTheme = () => useContext(ThemeContext)
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ const KeyboardControllerRefCountContext = createContext<{
|
|||||||
incrementRefCount: () => {},
|
incrementRefCount: () => {},
|
||||||
decrementRefCount: () => {},
|
decrementRefCount: () => {},
|
||||||
})
|
})
|
||||||
|
KeyboardControllerRefCountContext.displayName =
|
||||||
|
'KeyboardControllerRefCountContext'
|
||||||
|
|
||||||
export function KeyboardControllerProvider({
|
export function KeyboardControllerProvider({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -4,8 +4,11 @@ import {useFocusEffect} from '@react-navigation/native'
|
|||||||
type HideBottomBarBorderSetter = () => () => void
|
type HideBottomBarBorderSetter = () => () => void
|
||||||
|
|
||||||
const HideBottomBarBorderContext = createContext<boolean>(false)
|
const HideBottomBarBorderContext = createContext<boolean>(false)
|
||||||
|
HideBottomBarBorderContext.displayName = 'HideBottomBarBorderContext'
|
||||||
const HideBottomBarBorderSetterContext =
|
const HideBottomBarBorderSetterContext =
|
||||||
createContext<HideBottomBarBorderSetter | null>(null)
|
createContext<HideBottomBarBorderSetter | null>(null)
|
||||||
|
HideBottomBarBorderSetterContext.displayName =
|
||||||
|
'HideBottomBarBorderSetterContext'
|
||||||
|
|
||||||
export function useHideBottomBarBorderSetter() {
|
export function useHideBottomBarBorderSetter() {
|
||||||
const hideBottomBarBorder = useContext(HideBottomBarBorderSetterContext)
|
const hideBottomBarBorder = useContext(HideBottomBarBorderSetterContext)
|
||||||
|
|||||||
@@ -147,6 +147,7 @@ function toStringRecord<E extends keyof MetricEvents>(
|
|||||||
// and it's been difficult to get it to behave in a predictable way.
|
// and it's been difficult to get it to behave in a predictable way.
|
||||||
// Our own cache ensures consistent evaluation within a single session.
|
// Our own cache ensures consistent evaluation within a single session.
|
||||||
const GateCache = React.createContext<Map<string, boolean> | null>(null)
|
const GateCache = React.createContext<Map<string, boolean> | null>(null)
|
||||||
|
GateCache.displayName = 'StatsigGateCacheContext'
|
||||||
|
|
||||||
type GateOptions = {
|
type GateOptions = {
|
||||||
dangerouslyDisableExposureLogging?: boolean
|
dangerouslyDisableExposureLogging?: boolean
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ interface IAvatarContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const AvatarContext = React.createContext<IAvatarContext>({} as IAvatarContext)
|
const AvatarContext = React.createContext<IAvatarContext>({} as IAvatarContext)
|
||||||
|
AvatarContext.displayName = 'AvatarContext'
|
||||||
export const useAvatar = () => React.useContext(AvatarContext)
|
export const useAvatar = () => React.useContext(AvatarContext)
|
||||||
|
|
||||||
const randomColor =
|
const randomColor =
|
||||||
|
|||||||
@@ -3,7 +3,10 @@ import {msg} from '@lingui/macro'
|
|||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {logger} from '#/logger'
|
import {logger} from '#/logger'
|
||||||
import {AvatarColor, Emoji} from '#/screens/Onboarding/StepProfile/types'
|
import {
|
||||||
|
type AvatarColor,
|
||||||
|
type Emoji,
|
||||||
|
} from '#/screens/Onboarding/StepProfile/types'
|
||||||
|
|
||||||
export type OnboardingState = {
|
export type OnboardingState = {
|
||||||
hasPrev: boolean
|
hasPrev: boolean
|
||||||
@@ -147,6 +150,7 @@ export const Context = React.createContext<{
|
|||||||
state: {...initialState},
|
state: {...initialState},
|
||||||
dispatch: () => {},
|
dispatch: () => {},
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'OnboardingContext'
|
||||||
|
|
||||||
export function reducer(
|
export function reducer(
|
||||||
s: OnboardingState,
|
s: OnboardingState,
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ const ItemContext = createContext({
|
|||||||
destructive: false,
|
destructive: false,
|
||||||
withinGroup: false,
|
withinGroup: false,
|
||||||
})
|
})
|
||||||
|
ItemContext.displayName = 'SettingsListItemContext'
|
||||||
|
|
||||||
const Portal = createPortalGroup()
|
const Portal = createPortalGroup()
|
||||||
|
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ interface IContext {
|
|||||||
dispatch: React.Dispatch<SignupAction>
|
dispatch: React.Dispatch<SignupAction>
|
||||||
}
|
}
|
||||||
export const SignupContext = React.createContext<IContext>({} as IContext)
|
export const SignupContext = React.createContext<IContext>({} as IContext)
|
||||||
|
SignupContext.displayName = 'SignupContext'
|
||||||
export const useSignupContext = () => React.useContext(SignupContext)
|
export const useSignupContext = () => React.useContext(SignupContext)
|
||||||
|
|
||||||
export function useSubmitSignup() {
|
export function useSubmitSignup() {
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ const StateContext = React.createContext<TStateContext>([
|
|||||||
{} as State,
|
{} as State,
|
||||||
(_: Action) => {},
|
(_: Action) => {},
|
||||||
])
|
])
|
||||||
|
StateContext.displayName = 'StarterPackWizardStateContext'
|
||||||
export const useWizardState = () => React.useContext(StateContext)
|
export const useWizardState = () => React.useContext(StateContext)
|
||||||
|
|
||||||
function reducer(state: State, action: Action): State {
|
function reducer(state: State, action: Action): State {
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ const Context = React.createContext({
|
|||||||
reduceMotionEnabled: false,
|
reduceMotionEnabled: false,
|
||||||
screenReaderEnabled: false,
|
screenReaderEnabled: false,
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'A11yContext'
|
||||||
|
|
||||||
export function useA11y() {
|
export function useA11y() {
|
||||||
return React.useContext(Context)
|
return React.useContext(Context)
|
||||||
|
|||||||
@@ -28,11 +28,13 @@ const AgeAssuranceContext = createContext<AgeAssuranceContextType>({
|
|||||||
lastInitiatedAt: undefined,
|
lastInitiatedAt: undefined,
|
||||||
isAgeRestricted: false,
|
isAgeRestricted: false,
|
||||||
})
|
})
|
||||||
|
AgeAssuranceContext.displayName = 'AgeAssuranceContext'
|
||||||
|
|
||||||
const AgeAssuranceAPIContext = createContext<AgeAssuranceAPIContextType>({
|
const AgeAssuranceAPIContext = createContext<AgeAssuranceAPIContextType>({
|
||||||
// @ts-ignore can't be bothered to type this
|
// @ts-ignore can't be bothered to type this
|
||||||
refetch: () => Promise.resolve(),
|
refetch: () => Promise.resolve(),
|
||||||
})
|
})
|
||||||
|
AgeAssuranceAPIContext.displayName = 'AgeAssuranceAPIContext'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Low-level provider for fetching age assurance state on app load. Do not add
|
* Low-level provider for fetching age assurance state on app load. Do not add
|
||||||
|
|||||||
Vendored
+2
@@ -7,9 +7,11 @@ type StateContext = Map<string, boolean>
|
|||||||
type SetStateContext = (uri: string, value: boolean) => void
|
type SetStateContext = (uri: string, value: boolean) => void
|
||||||
|
|
||||||
const stateContext = React.createContext<StateContext>(new Map())
|
const stateContext = React.createContext<StateContext>(new Map())
|
||||||
|
stateContext.displayName = 'ThreadMutesStateContext'
|
||||||
const setStateContext = React.createContext<SetStateContext>(
|
const setStateContext = React.createContext<SetStateContext>(
|
||||||
(_: string) => false,
|
(_: string) => false,
|
||||||
)
|
)
|
||||||
|
setStateContext.displayName = 'ThreadMutesSetStateContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [state, setState] = React.useState<StateContext>(() => new Map())
|
const [state, setState] = React.useState<StateContext>(() => new Map())
|
||||||
|
|||||||
@@ -26,10 +26,12 @@ interface IDialogControlContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DialogContext = React.createContext<IDialogContext>({} as IDialogContext)
|
const DialogContext = React.createContext<IDialogContext>({} as IDialogContext)
|
||||||
|
DialogContext.displayName = 'DialogContext'
|
||||||
|
|
||||||
const DialogControlContext = React.createContext<IDialogControlContext>(
|
const DialogControlContext = React.createContext<IDialogControlContext>(
|
||||||
{} as IDialogControlContext,
|
{} as IDialogControlContext,
|
||||||
)
|
)
|
||||||
|
DialogControlContext.displayName = 'DialogControlContext'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The number of dialogs that are fully expanded. This is used to determine the background color of the status bar
|
* The number of dialogs that are fully expanded. This is used to determine the background color of the status bar
|
||||||
@@ -107,3 +109,4 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
|
|||||||
</DialogContext.Provider>
|
</DialogContext.Provider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Provider.displayName = 'DialogsProvider'
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ const stateContext = createContext<StateContext>({
|
|||||||
sendInteraction: (_interaction: AppBskyFeedDefs.Interaction) => {},
|
sendInteraction: (_interaction: AppBskyFeedDefs.Interaction) => {},
|
||||||
feedDescriptor: undefined,
|
feedDescriptor: undefined,
|
||||||
})
|
})
|
||||||
|
stateContext.displayName = 'FeedFeedbackContext'
|
||||||
|
|
||||||
export function useFeedFeedback(
|
export function useFeedFeedback(
|
||||||
feed: FeedDescriptor | undefined,
|
feed: FeedDescriptor | undefined,
|
||||||
|
|||||||
@@ -154,6 +154,7 @@ type Context = {
|
|||||||
const context = React.createContext<Context>({
|
const context = React.createContext<Context>({
|
||||||
geolocation: DEFAULT_GEOLOCATION,
|
geolocation: DEFAULT_GEOLOCATION,
|
||||||
})
|
})
|
||||||
|
context.displayName = 'GeolocationContext'
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
const [geolocation, setGeolocation] = React.useState(() => {
|
const [geolocation, setGeolocation] = React.useState(() => {
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ const Context = createContext<{
|
|||||||
register: () => {},
|
register: () => {},
|
||||||
unregister: () => {},
|
unregister: () => {},
|
||||||
})
|
})
|
||||||
|
Context.displayName = 'GlobalGestureEventsContext'
|
||||||
|
|
||||||
export function GlobalGestureEventsProvider({
|
export function GlobalGestureEventsProvider({
|
||||||
children,
|
children,
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ type StateContext = boolean
|
|||||||
type ApiContext = (hasNew: boolean) => void
|
type ApiContext = (hasNew: boolean) => void
|
||||||
|
|
||||||
const stateContext = React.createContext<StateContext>(false)
|
const stateContext = React.createContext<StateContext>(false)
|
||||||
|
stateContext.displayName = 'HomeBadgeStateContext'
|
||||||
const apiContext = React.createContext<ApiContext>((_: boolean) => {})
|
const apiContext = React.createContext<ApiContext>((_: boolean) => {})
|
||||||
|
apiContext.displayName = 'HomeBadgeApiContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [state, setState] = React.useState(false)
|
const [state, setState] = React.useState(false)
|
||||||
|
|||||||
@@ -10,9 +10,11 @@ type ApiContext = {
|
|||||||
const stateContext = React.createContext<StateContext>(
|
const stateContext = React.createContext<StateContext>(
|
||||||
persisted.defaults.invites,
|
persisted.defaults.invites,
|
||||||
)
|
)
|
||||||
|
stateContext.displayName = 'InvitesStateContext'
|
||||||
const apiContext = React.createContext<ApiContext>({
|
const apiContext = React.createContext<ApiContext>({
|
||||||
setInviteCopied(_: string) {},
|
setInviteCopied(_: string) {},
|
||||||
})
|
})
|
||||||
|
apiContext.displayName = 'InvitesApiContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [state, setState] = React.useState(persisted.get('invites'))
|
const [state, setState] = React.useState(persisted.get('invites'))
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React from 'react'
|
|||||||
import {nanoid} from 'nanoid/non-secure'
|
import {nanoid} from 'nanoid/non-secure'
|
||||||
|
|
||||||
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
||||||
import {ImageSource} from '#/view/com/lightbox/ImageViewing/@types'
|
import {type ImageSource} from '#/view/com/lightbox/ImageViewing/@types'
|
||||||
|
|
||||||
export type Lightbox = {
|
export type Lightbox = {
|
||||||
id: string
|
id: string
|
||||||
@@ -15,6 +15,7 @@ const LightboxContext = React.createContext<{
|
|||||||
}>({
|
}>({
|
||||||
activeLightbox: null,
|
activeLightbox: null,
|
||||||
})
|
})
|
||||||
|
LightboxContext.displayName = 'LightboxContext'
|
||||||
|
|
||||||
const LightboxControlContext = React.createContext<{
|
const LightboxControlContext = React.createContext<{
|
||||||
openLightbox: (lightbox: Omit<Lightbox, 'id'>) => void
|
openLightbox: (lightbox: Omit<Lightbox, 'id'>) => void
|
||||||
@@ -23,6 +24,7 @@ const LightboxControlContext = React.createContext<{
|
|||||||
openLightbox: () => {},
|
openLightbox: () => {},
|
||||||
closeLightbox: () => false,
|
closeLightbox: () => false,
|
||||||
})
|
})
|
||||||
|
LightboxControlContext.displayName = 'LightboxControlContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [activeLightbox, setActiveLightbox] = React.useState<Lightbox | null>(
|
const [activeLightbox, setActiveLightbox] = React.useState<Lightbox | null>(
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import {useAgent} from '#/state/session'
|
|||||||
export * from '#/state/messages/convo/util'
|
export * from '#/state/messages/convo/util'
|
||||||
|
|
||||||
const ChatContext = React.createContext<ConvoState | null>(null)
|
const ChatContext = React.createContext<ConvoState | null>(null)
|
||||||
|
ChatContext.displayName = 'ChatContext'
|
||||||
|
|
||||||
export function useConvo() {
|
export function useConvo() {
|
||||||
const ctx = useContext(ChatContext)
|
const ctx = useContext(ChatContext)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const CurrentConvoIdContext = React.createContext<{
|
|||||||
currentConvoId: undefined,
|
currentConvoId: undefined,
|
||||||
setCurrentConvoId: () => {},
|
setCurrentConvoId: () => {},
|
||||||
})
|
})
|
||||||
|
CurrentConvoIdContext.displayName = 'CurrentConvoIdContext'
|
||||||
|
|
||||||
export function useCurrentConvoId() {
|
export function useCurrentConvoId() {
|
||||||
const ctx = React.useContext(CurrentConvoIdContext)
|
const ctx = React.useContext(CurrentConvoIdContext)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {useAgent, useSession} from '#/state/session'
|
|||||||
const MessagesEventBusContext = React.createContext<MessagesEventBus | null>(
|
const MessagesEventBusContext = React.createContext<MessagesEventBus | null>(
|
||||||
null,
|
null,
|
||||||
)
|
)
|
||||||
|
MessagesEventBusContext.displayName = 'MessagesEventBusContext'
|
||||||
|
|
||||||
export function useMessagesEventBus() {
|
export function useMessagesEventBus() {
|
||||||
const ctx = React.useContext(MessagesEventBusContext)
|
const ctx = React.useContext(MessagesEventBusContext)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ const MessageDraftsContext = React.createContext<{
|
|||||||
state: State
|
state: State
|
||||||
dispatch: React.Dispatch<Actions>
|
dispatch: React.Dispatch<Actions>
|
||||||
} | null>(null)
|
} | null>(null)
|
||||||
|
MessageDraftsContext.displayName = 'MessageDraftsContext'
|
||||||
|
|
||||||
function useMessageDraftsContext() {
|
function useMessageDraftsContext() {
|
||||||
const ctx = React.useContext(MessageDraftsContext)
|
const ctx = React.useContext(MessageDraftsContext)
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ const ModalContext = React.createContext<{
|
|||||||
isModalActive: false,
|
isModalActive: false,
|
||||||
activeModals: [],
|
activeModals: [],
|
||||||
})
|
})
|
||||||
|
ModalContext.displayName = 'ModalContext'
|
||||||
|
|
||||||
const ModalControlContext = React.createContext<{
|
const ModalControlContext = React.createContext<{
|
||||||
openModal: (modal: Modal) => void
|
openModal: (modal: Modal) => void
|
||||||
@@ -80,6 +81,7 @@ const ModalControlContext = React.createContext<{
|
|||||||
closeModal: () => false,
|
closeModal: () => false,
|
||||||
closeAllModals: () => false,
|
closeAllModals: () => false,
|
||||||
})
|
})
|
||||||
|
ModalControlContext.displayName = 'ModalControlContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [activeModals, setActiveModals] = React.useState<Modal[]>([])
|
const [activeModals, setActiveModals] = React.useState<Modal[]>([])
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ type SetContext = (v: persisted.Schema['requireAltTextEnabled']) => void
|
|||||||
const stateContext = React.createContext<StateContext>(
|
const stateContext = React.createContext<StateContext>(
|
||||||
persisted.defaults.requireAltTextEnabled,
|
persisted.defaults.requireAltTextEnabled,
|
||||||
)
|
)
|
||||||
|
stateContext.displayName = 'AltTextRequiredStateContext'
|
||||||
const setContext = React.createContext<SetContext>(
|
const setContext = React.createContext<SetContext>(
|
||||||
(_: persisted.Schema['requireAltTextEnabled']) => {},
|
(_: persisted.Schema['requireAltTextEnabled']) => {},
|
||||||
)
|
)
|
||||||
|
setContext.displayName = 'AltTextRequiredSetContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [state, setState] = React.useState(
|
const [state, setState] = React.useState(
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ type SetContext = (v: boolean) => void
|
|||||||
const stateContext = React.createContext<StateContext>(
|
const stateContext = React.createContext<StateContext>(
|
||||||
Boolean(persisted.defaults.disableAutoplay),
|
Boolean(persisted.defaults.disableAutoplay),
|
||||||
)
|
)
|
||||||
|
stateContext.displayName = 'AutoplayStateContext'
|
||||||
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
||||||
|
setContext.displayName = 'AutoplaySetContext'
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
const [state, setState] = React.useState(
|
const [state, setState] = React.useState(
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ type SetContext = (v: boolean) => void
|
|||||||
const stateContext = React.createContext<StateContext>(
|
const stateContext = React.createContext<StateContext>(
|
||||||
Boolean(persisted.defaults.disableHaptics),
|
Boolean(persisted.defaults.disableHaptics),
|
||||||
)
|
)
|
||||||
|
stateContext.displayName = 'DisableHapticsStateContext'
|
||||||
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
||||||
|
setContext.displayName = 'DisableHapticsSetContext'
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
const [state, setState] = React.useState(
|
const [state, setState] = React.useState(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import {EmbedPlayerSource} from '#/lib/strings/embed-player'
|
import {type EmbedPlayerSource} from '#/lib/strings/embed-player'
|
||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
|
|
||||||
type StateContext = persisted.Schema['externalEmbeds']
|
type StateContext = persisted.Schema['externalEmbeds']
|
||||||
@@ -12,7 +12,9 @@ type SetContext = (
|
|||||||
const stateContext = React.createContext<StateContext>(
|
const stateContext = React.createContext<StateContext>(
|
||||||
persisted.defaults.externalEmbeds,
|
persisted.defaults.externalEmbeds,
|
||||||
)
|
)
|
||||||
|
stateContext.displayName = 'ExternalEmbedsPrefsStateContext'
|
||||||
const setContext = React.createContext<SetContext>({} as SetContext)
|
const setContext = React.createContext<SetContext>({} as SetContext)
|
||||||
|
setContext.displayName = 'ExternalEmbedsPrefsSetContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [state, setState] = React.useState(persisted.get('externalEmbeds'))
|
const [state, setState] = React.useState(persisted.get('externalEmbeds'))
|
||||||
|
|||||||
@@ -14,10 +14,12 @@ type ApiContext = {
|
|||||||
const stateContext = React.createContext<StateContext>(
|
const stateContext = React.createContext<StateContext>(
|
||||||
persisted.defaults.hiddenPosts,
|
persisted.defaults.hiddenPosts,
|
||||||
)
|
)
|
||||||
|
stateContext.displayName = 'HiddenPostsStateContext'
|
||||||
const apiContext = React.createContext<ApiContext>({
|
const apiContext = React.createContext<ApiContext>({
|
||||||
hidePost: () => {},
|
hidePost: () => {},
|
||||||
unhidePost: () => {},
|
unhidePost: () => {},
|
||||||
})
|
})
|
||||||
|
apiContext.displayName = 'HiddenPostsApiContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [state, setState] = React.useState(persisted.get('hiddenPosts'))
|
const [state, setState] = React.useState(persisted.get('hiddenPosts'))
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ type SetContext = (v: persisted.Schema['useInAppBrowser']) => void
|
|||||||
const stateContext = React.createContext<StateContext>(
|
const stateContext = React.createContext<StateContext>(
|
||||||
persisted.defaults.useInAppBrowser,
|
persisted.defaults.useInAppBrowser,
|
||||||
)
|
)
|
||||||
|
stateContext.displayName = 'InAppBrowserStateContext'
|
||||||
const setContext = React.createContext<SetContext>(
|
const setContext = React.createContext<SetContext>(
|
||||||
(_: persisted.Schema['useInAppBrowser']) => {},
|
(_: persisted.Schema['useInAppBrowser']) => {},
|
||||||
)
|
)
|
||||||
|
setContext.displayName = 'InAppBrowserSetContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [state, setState] = React.useState(persisted.get('useInAppBrowser'))
|
const [state, setState] = React.useState(persisted.get('useInAppBrowser'))
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ type StateContext = persisted.Schema['kawaii']
|
|||||||
const stateContext = React.createContext<StateContext>(
|
const stateContext = React.createContext<StateContext>(
|
||||||
persisted.defaults.kawaii,
|
persisted.defaults.kawaii,
|
||||||
)
|
)
|
||||||
|
stateContext.displayName = 'KawaiiStateContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [state, setState] = React.useState(persisted.get('kawaii'))
|
const [state, setState] = React.useState(persisted.get('kawaii'))
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {AppBskyLabelerDefs, InterpretedLabelValueDefinition} from '@atproto/api'
|
import {
|
||||||
|
type AppBskyLabelerDefs,
|
||||||
|
type InterpretedLabelValueDefinition,
|
||||||
|
} from '@atproto/api'
|
||||||
|
|
||||||
import {useLabelDefinitionsQuery} from '../queries/preferences'
|
import {useLabelDefinitionsQuery} from '../queries/preferences'
|
||||||
|
|
||||||
@@ -12,6 +15,7 @@ const stateContext = React.createContext<StateContext>({
|
|||||||
labelDefs: {},
|
labelDefs: {},
|
||||||
labelers: [],
|
labelers: [],
|
||||||
})
|
})
|
||||||
|
stateContext.displayName = 'LabelDefsStateContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const state = useLabelDefinitionsQuery()
|
const state = useLabelDefinitionsQuery()
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
|
|
||||||
import {AppLanguage} from '#/locale/languages'
|
import {type AppLanguage} from '#/locale/languages'
|
||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
|
|
||||||
type SetStateCb = (
|
type SetStateCb = (
|
||||||
@@ -20,6 +20,7 @@ type ApiContext = {
|
|||||||
const stateContext = React.createContext<StateContext>(
|
const stateContext = React.createContext<StateContext>(
|
||||||
persisted.defaults.languagePrefs,
|
persisted.defaults.languagePrefs,
|
||||||
)
|
)
|
||||||
|
stateContext.displayName = 'LanguagePrefsStateContext'
|
||||||
const apiContext = React.createContext<ApiContext>({
|
const apiContext = React.createContext<ApiContext>({
|
||||||
setPrimaryLanguage: (_: string) => {},
|
setPrimaryLanguage: (_: string) => {},
|
||||||
setPostLanguage: (_: string) => {},
|
setPostLanguage: (_: string) => {},
|
||||||
@@ -29,6 +30,7 @@ const apiContext = React.createContext<ApiContext>({
|
|||||||
savePostLanguageToHistory: () => {},
|
savePostLanguageToHistory: () => {},
|
||||||
setAppLanguage: (_: AppLanguage) => {},
|
setAppLanguage: (_: AppLanguage) => {},
|
||||||
})
|
})
|
||||||
|
apiContext.displayName = 'LanguagePrefsApiContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [state, setState] = React.useState(persisted.get('languagePrefs'))
|
const [state, setState] = React.useState(persisted.get('languagePrefs'))
|
||||||
|
|||||||
@@ -8,9 +8,11 @@ type SetContext = (v: persisted.Schema['largeAltBadgeEnabled']) => void
|
|||||||
const stateContext = React.createContext<StateContext>(
|
const stateContext = React.createContext<StateContext>(
|
||||||
persisted.defaults.largeAltBadgeEnabled,
|
persisted.defaults.largeAltBadgeEnabled,
|
||||||
)
|
)
|
||||||
|
stateContext.displayName = 'LargeAltBadgeStateContext'
|
||||||
const setContext = React.createContext<SetContext>(
|
const setContext = React.createContext<SetContext>(
|
||||||
(_: persisted.Schema['largeAltBadgeEnabled']) => {},
|
(_: persisted.Schema['largeAltBadgeEnabled']) => {},
|
||||||
)
|
)
|
||||||
|
setContext.displayName = 'LargeAltBadgeSetContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [state, setState] = React.useState(
|
const [state, setState] = React.useState(
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, {createContext, useContext, useMemo} from 'react'
|
import {createContext, useContext, useMemo} from 'react'
|
||||||
import {BskyAgent, ModerationOpts} from '@atproto/api'
|
import {BskyAgent, type ModerationOpts} from '@atproto/api'
|
||||||
|
|
||||||
import {useHiddenPosts, useLabelDefinitions} from '#/state/preferences'
|
import {useHiddenPosts, useLabelDefinitions} from '#/state/preferences'
|
||||||
import {DEFAULT_LOGGED_OUT_LABEL_PREFERENCES} from '#/state/queries/preferences/moderation'
|
import {DEFAULT_LOGGED_OUT_LABEL_PREFERENCES} from '#/state/queries/preferences/moderation'
|
||||||
@@ -9,11 +9,13 @@ import {usePreferencesQuery} from '../queries/preferences'
|
|||||||
export const moderationOptsContext = createContext<ModerationOpts | undefined>(
|
export const moderationOptsContext = createContext<ModerationOpts | undefined>(
|
||||||
undefined,
|
undefined,
|
||||||
)
|
)
|
||||||
|
moderationOptsContext.displayName = 'ModerationOptsContext'
|
||||||
|
|
||||||
// used in the moderation state devtool
|
// used in the moderation state devtool
|
||||||
export const moderationOptsOverrideContext = createContext<
|
export const moderationOptsOverrideContext = createContext<
|
||||||
ModerationOpts | undefined
|
ModerationOpts | undefined
|
||||||
>(undefined)
|
>(undefined)
|
||||||
|
moderationOptsOverrideContext.displayName = 'ModerationOptsOverrideContext'
|
||||||
|
|
||||||
export function useModerationOpts() {
|
export function useModerationOpts() {
|
||||||
return useContext(moderationOptsContext)
|
return useContext(moderationOptsContext)
|
||||||
|
|||||||
@@ -8,7 +8,9 @@ type SetContext = (v: boolean) => void
|
|||||||
const stateContext = React.createContext<StateContext>(
|
const stateContext = React.createContext<StateContext>(
|
||||||
Boolean(persisted.defaults.subtitlesEnabled),
|
Boolean(persisted.defaults.subtitlesEnabled),
|
||||||
)
|
)
|
||||||
|
stateContext.displayName = 'SubtitlesStateContext'
|
||||||
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
||||||
|
setContext.displayName = 'SubtitlesSetContext'
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
const [state, setState] = React.useState(
|
const [state, setState] = React.useState(
|
||||||
|
|||||||
@@ -22,10 +22,12 @@ const StateContext = React.createContext<StateContext>({
|
|||||||
trendingDisabled: Boolean(persisted.defaults.trendingDisabled),
|
trendingDisabled: Boolean(persisted.defaults.trendingDisabled),
|
||||||
trendingVideoDisabled: Boolean(persisted.defaults.trendingVideoDisabled),
|
trendingVideoDisabled: Boolean(persisted.defaults.trendingVideoDisabled),
|
||||||
})
|
})
|
||||||
|
StateContext.displayName = 'TrendingStateContext'
|
||||||
const ApiContext = React.createContext<ApiContext>({
|
const ApiContext = React.createContext<ApiContext>({
|
||||||
setTrendingDisabled() {},
|
setTrendingDisabled() {},
|
||||||
setTrendingVideoDisabled() {},
|
setTrendingVideoDisabled() {},
|
||||||
})
|
})
|
||||||
|
ApiContext.displayName = 'TrendingApiContext'
|
||||||
|
|
||||||
function usePersistedBooleanValue<T extends keyof persisted.Schema>(key: T) {
|
function usePersistedBooleanValue<T extends keyof persisted.Schema>(key: T) {
|
||||||
const [value, _set] = React.useState(() => {
|
const [value, _set] = React.useState(() => {
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ type StateContext = boolean | undefined
|
|||||||
type SetContext = (v: boolean) => void
|
type SetContext = (v: boolean) => void
|
||||||
|
|
||||||
const stateContext = React.createContext<StateContext>(false)
|
const stateContext = React.createContext<StateContext>(false)
|
||||||
|
stateContext.displayName = 'UsedStarterPacksStateContext'
|
||||||
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
||||||
|
setContext.displayName = 'UsedStarterPacksSetContext'
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
const [state, setState] = React.useState<StateContext>(() =>
|
const [state, setState] = React.useState<StateContext>(() =>
|
||||||
|
|||||||
@@ -62,6 +62,7 @@ const ListConvosContext = createContext<{
|
|||||||
accepted: ChatBskyConvoDefs.ConvoView[]
|
accepted: ChatBskyConvoDefs.ConvoView[]
|
||||||
request: ChatBskyConvoDefs.ConvoView[]
|
request: ChatBskyConvoDefs.ConvoView[]
|
||||||
} | null>(null)
|
} | null>(null)
|
||||||
|
ListConvosContext.displayName = 'ListConvosContext'
|
||||||
|
|
||||||
export function useListConvos() {
|
export function useListConvos() {
|
||||||
const ctx = useContext(ListConvosContext)
|
const ctx = useContext(ListConvosContext)
|
||||||
|
|||||||
@@ -35,12 +35,14 @@ interface ApiContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const stateContext = React.createContext<StateContext>('')
|
const stateContext = React.createContext<StateContext>('')
|
||||||
|
stateContext.displayName = 'NotificationsUnreadStateContext'
|
||||||
|
|
||||||
const apiContext = React.createContext<ApiContext>({
|
const apiContext = React.createContext<ApiContext>({
|
||||||
async markAllRead() {},
|
async markAllRead() {},
|
||||||
async checkUnread() {},
|
async checkUnread() {},
|
||||||
getCachedUnreadPage: () => undefined,
|
getCachedUnreadPage: () => undefined,
|
||||||
})
|
})
|
||||||
|
apiContext.displayName = 'NotificationsUnreadApiContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
|
|||||||
@@ -16,8 +16,10 @@ type LiveNowContext = {
|
|||||||
const TrendingContext = createContext<TrendingContext>({
|
const TrendingContext = createContext<TrendingContext>({
|
||||||
enabled: false,
|
enabled: false,
|
||||||
})
|
})
|
||||||
|
TrendingContext.displayName = 'TrendingContext'
|
||||||
|
|
||||||
const LiveNowContext = createContext<LiveNowContext | null>(null)
|
const LiveNowContext = createContext<LiveNowContext | null>(null)
|
||||||
|
LiveNowContext.displayName = 'LiveNowContext'
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
const langPrefs = useLanguagePrefs()
|
const langPrefs = useLanguagePrefs()
|
||||||
|
|||||||
@@ -30,8 +30,10 @@ const StateContext = React.createContext<SessionStateContext>({
|
|||||||
currentAccount: undefined,
|
currentAccount: undefined,
|
||||||
hasSession: false,
|
hasSession: false,
|
||||||
})
|
})
|
||||||
|
StateContext.displayName = 'SessionStateContext'
|
||||||
|
|
||||||
const AgentContext = React.createContext<BskyAgent | null>(null)
|
const AgentContext = React.createContext<BskyAgent | null>(null)
|
||||||
|
AgentContext.displayName = 'SessionAgentContext'
|
||||||
|
|
||||||
const ApiContext = React.createContext<SessionApiContext>({
|
const ApiContext = React.createContext<SessionApiContext>({
|
||||||
createAccount: async () => {},
|
createAccount: async () => {},
|
||||||
@@ -42,6 +44,7 @@ const ApiContext = React.createContext<SessionApiContext>({
|
|||||||
removeAccount: () => {},
|
removeAccount: () => {},
|
||||||
partialRefreshSession: async () => {},
|
partialRefreshSession: async () => {},
|
||||||
})
|
})
|
||||||
|
ApiContext.displayName = 'SessionApiContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const cancelPendingTask = useOneTaskAtATime()
|
const cancelPendingTask = useOneTaskAtATime()
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ const stateContext = React.createContext<StateContext>({
|
|||||||
colorMode: 'system',
|
colorMode: 'system',
|
||||||
darkTheme: 'dark',
|
darkTheme: 'dark',
|
||||||
})
|
})
|
||||||
|
stateContext.displayName = 'ColorModeStateContext'
|
||||||
const setContext = React.createContext<SetContext>({} as SetContext)
|
const setContext = React.createContext<SetContext>({} as SetContext)
|
||||||
|
setContext.displayName = 'ColorModeSetContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [colorMode, setColorMode] = React.useState(persisted.get('colorMode'))
|
const [colorMode, setColorMode] = React.useState(persisted.get('colorMode'))
|
||||||
|
|||||||
@@ -51,12 +51,14 @@ type ControlsContext = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const stateContext = React.createContext<StateContext>(undefined)
|
const stateContext = React.createContext<StateContext>(undefined)
|
||||||
|
stateContext.displayName = 'ComposerStateContext'
|
||||||
const controlsContext = React.createContext<ControlsContext>({
|
const controlsContext = React.createContext<ControlsContext>({
|
||||||
openComposer(_opts: ComposerOpts) {},
|
openComposer(_opts: ComposerOpts) {},
|
||||||
closeComposer() {
|
closeComposer() {
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
controlsContext.displayName = 'ComposerControlsContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ type StateContext = boolean
|
|||||||
type SetContext = (v: boolean) => void
|
type SetContext = (v: boolean) => void
|
||||||
|
|
||||||
const stateContext = React.createContext<StateContext>(false)
|
const stateContext = React.createContext<StateContext>(false)
|
||||||
|
stateContext.displayName = 'DrawerOpenStateContext'
|
||||||
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
||||||
|
setContext.displayName = 'DrawerOpenSetContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [state, setState] = React.useState(false)
|
const [state, setState] = React.useState(false)
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ type StateContext = boolean
|
|||||||
type SetContext = (v: boolean) => void
|
type SetContext = (v: boolean) => void
|
||||||
|
|
||||||
const stateContext = React.createContext<StateContext>(false)
|
const stateContext = React.createContext<StateContext>(false)
|
||||||
|
stateContext.displayName = 'DrawerSwipeDisabledStateContext'
|
||||||
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
||||||
|
setContext.displayName = 'DrawerSwipeDisabledSetContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [state, setState] = React.useState(false)
|
const [state, setState] = React.useState(false)
|
||||||
|
|||||||
@@ -39,12 +39,14 @@ const StateContext = React.createContext<State>({
|
|||||||
showLoggedOut: false,
|
showLoggedOut: false,
|
||||||
requestedAccountSwitchTo: undefined,
|
requestedAccountSwitchTo: undefined,
|
||||||
})
|
})
|
||||||
|
StateContext.displayName = 'LoggedOutStateContext'
|
||||||
|
|
||||||
const ControlsContext = React.createContext<Controls>({
|
const ControlsContext = React.createContext<Controls>({
|
||||||
setShowLoggedOut: () => {},
|
setShowLoggedOut: () => {},
|
||||||
requestSwitchToAccount: () => {},
|
requestSwitchToAccount: () => {},
|
||||||
clearRequestedAccount: () => {},
|
clearRequestedAccount: () => {},
|
||||||
})
|
})
|
||||||
|
ControlsContext.displayName = 'LoggedOutControlsContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const activeStarterPack = useActiveStarterPack()
|
const activeStarterPack = useActiveStarterPack()
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {SharedValue, useSharedValue, withSpring} from 'react-native-reanimated'
|
import {
|
||||||
|
type SharedValue,
|
||||||
|
useSharedValue,
|
||||||
|
withSpring,
|
||||||
|
} from 'react-native-reanimated'
|
||||||
|
|
||||||
type StateContext = {
|
type StateContext = {
|
||||||
headerMode: SharedValue<number>
|
headerMode: SharedValue<number>
|
||||||
@@ -29,7 +33,9 @@ const stateContext = React.createContext<StateContext>({
|
|||||||
set() {},
|
set() {},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
stateContext.displayName = 'MinimalModeStateContext'
|
||||||
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
const setContext = React.createContext<SetContext>((_: boolean) => {})
|
||||||
|
setContext.displayName = 'MinimalModeSetContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const headerMode = useSharedValue(0)
|
const headerMode = useSharedValue(0)
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ export type DispatchContext = (action: Action) => void
|
|||||||
const stateContext = React.createContext<StateContext>(
|
const stateContext = React.createContext<StateContext>(
|
||||||
compute(persisted.defaults.onboarding),
|
compute(persisted.defaults.onboarding),
|
||||||
)
|
)
|
||||||
|
stateContext.displayName = 'OnboardingStateContext'
|
||||||
const dispatchContext = React.createContext<DispatchContext>((_: Action) => {})
|
const dispatchContext = React.createContext<DispatchContext>((_: Action) => {})
|
||||||
|
dispatchContext.displayName = 'OnboardingDispatchContext'
|
||||||
|
|
||||||
function reducer(state: StateContext, action: Action): StateContext {
|
function reducer(state: StateContext, action: Action): StateContext {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ const PostProgressContext = React.createContext<PostProgressState>({
|
|||||||
progress: 0,
|
progress: 0,
|
||||||
status: 'idle',
|
status: 'idle',
|
||||||
})
|
})
|
||||||
|
PostProgressContext.displayName = 'PostProgressContext'
|
||||||
|
|
||||||
export function Provider() {}
|
export function Provider() {}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {useLingui} from '@lingui/react'
|
|||||||
import {logEvent} from '#/lib/statsig/statsig'
|
import {logEvent} from '#/lib/statsig/statsig'
|
||||||
import {
|
import {
|
||||||
ProgressGuideToast,
|
ProgressGuideToast,
|
||||||
ProgressGuideToastRef,
|
type ProgressGuideToastRef,
|
||||||
} from '#/components/ProgressGuide/Toast'
|
} from '#/components/ProgressGuide/Toast'
|
||||||
import {
|
import {
|
||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
@@ -45,6 +45,7 @@ export type ProgressGuide =
|
|||||||
| undefined
|
| undefined
|
||||||
|
|
||||||
const ProgressGuideContext = React.createContext<ProgressGuide>(undefined)
|
const ProgressGuideContext = React.createContext<ProgressGuide>(undefined)
|
||||||
|
ProgressGuideContext.displayName = 'ProgressGuideContext'
|
||||||
|
|
||||||
const ProgressGuideControlContext = React.createContext<{
|
const ProgressGuideControlContext = React.createContext<{
|
||||||
startProgressGuide(guide: ProgressGuideName): void
|
startProgressGuide(guide: ProgressGuideName): void
|
||||||
@@ -55,6 +56,7 @@ const ProgressGuideControlContext = React.createContext<{
|
|||||||
endProgressGuide: () => {},
|
endProgressGuide: () => {},
|
||||||
captureAction: (_action: ProgressGuideAction, _count = 1) => {},
|
captureAction: (_action: ProgressGuideAction, _count = 1) => {},
|
||||||
})
|
})
|
||||||
|
ProgressGuideControlContext.displayName = 'ProgressGuideControlContext'
|
||||||
|
|
||||||
export function useProgressGuide(guide: ProgressGuideName) {
|
export function useProgressGuide(guide: ProgressGuideName) {
|
||||||
const ctx = React.useContext(ProgressGuideContext)
|
const ctx = React.useContext(ProgressGuideContext)
|
||||||
|
|||||||
@@ -2,13 +2,15 @@ import React from 'react'
|
|||||||
|
|
||||||
import {isWeb} from '#/platform/detection'
|
import {isWeb} from '#/platform/detection'
|
||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
import {FeedDescriptor} from '#/state/queries/post-feed'
|
import {type FeedDescriptor} from '#/state/queries/post-feed'
|
||||||
|
|
||||||
type StateContext = FeedDescriptor | null
|
type StateContext = FeedDescriptor | null
|
||||||
type SetContext = (v: FeedDescriptor) => void
|
type SetContext = (v: FeedDescriptor) => void
|
||||||
|
|
||||||
const stateContext = React.createContext<StateContext>(null)
|
const stateContext = React.createContext<StateContext>(null)
|
||||||
|
stateContext.displayName = 'SelectedFeedStateContext'
|
||||||
const setContext = React.createContext<SetContext>((_: string) => {})
|
const setContext = React.createContext<SetContext>((_: string) => {})
|
||||||
|
setContext.displayName = 'SelectedFeedSetContext'
|
||||||
|
|
||||||
function getInitialFeed(): FeedDescriptor | null {
|
function getInitialFeed(): FeedDescriptor | null {
|
||||||
if (isWeb) {
|
if (isWeb) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {SharedValue, useSharedValue} from 'react-native-reanimated'
|
import {type SharedValue, useSharedValue} from 'react-native-reanimated'
|
||||||
|
|
||||||
type StateContext = {
|
type StateContext = {
|
||||||
headerHeight: SharedValue<number>
|
headerHeight: SharedValue<number>
|
||||||
@@ -28,6 +28,7 @@ const stateContext = React.createContext<StateContext>({
|
|||||||
set() {},
|
set() {},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
stateContext.displayName = 'ShellLayoutContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const headerHeight = useSharedValue(0)
|
const headerHeight = useSharedValue(0)
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ type StateContext =
|
|||||||
type SetContext = (v: StateContext) => void
|
type SetContext = (v: StateContext) => void
|
||||||
|
|
||||||
const stateContext = React.createContext<StateContext>(undefined)
|
const stateContext = React.createContext<StateContext>(undefined)
|
||||||
|
stateContext.displayName = 'ActiveStarterPackStateContext'
|
||||||
const setContext = React.createContext<SetContext>((_: StateContext) => {})
|
const setContext = React.createContext<SetContext>((_: StateContext) => {})
|
||||||
|
setContext.displayName = 'ActiveStarterPackSetContext'
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
const [state, setState] = React.useState<StateContext>()
|
const [state, setState] = React.useState<StateContext>()
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import React from 'react'
|
|||||||
type StateContext = number
|
type StateContext = number
|
||||||
|
|
||||||
const stateContext = React.createContext<StateContext>(0)
|
const stateContext = React.createContext<StateContext>(0)
|
||||||
|
stateContext.displayName = 'TickEveryMinuteContext'
|
||||||
|
|
||||||
export function Provider({children}: React.PropsWithChildren<{}>) {
|
export function Provider({children}: React.PropsWithChildren<{}>) {
|
||||||
const [tick, setTick] = React.useState(Date.now())
|
const [tick, setTick] = React.useState(Date.now())
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ const StateContext = React.createContext<StateContext>({
|
|||||||
uris: new Set(),
|
uris: new Set(),
|
||||||
recentlyUnhiddenUris: new Set(),
|
recentlyUnhiddenUris: new Set(),
|
||||||
})
|
})
|
||||||
|
StateContext.displayName = 'ThreadgateHiddenRepliesStateContext'
|
||||||
|
|
||||||
const ApiContext = React.createContext<ApiContext>({
|
const ApiContext = React.createContext<ApiContext>({
|
||||||
addHiddenReplyUri: () => {},
|
addHiddenReplyUri: () => {},
|
||||||
removeHiddenReplyUri: () => {},
|
removeHiddenReplyUri: () => {},
|
||||||
})
|
})
|
||||||
|
ApiContext.displayName = 'ThreadgateHiddenRepliesApiContext'
|
||||||
|
|
||||||
export function Provider({children}: {children: React.ReactNode}) {
|
export function Provider({children}: {children: React.ReactNode}) {
|
||||||
const [uris, setHiddenReplyUris] = React.useState<Set<string>>(new Set())
|
const [uris, setHiddenReplyUris] = React.useState<Set<string>>(new Set())
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, {useContext} from 'react'
|
import React, {useContext} from 'react'
|
||||||
import {SharedValue} from 'react-native-reanimated'
|
import {type SharedValue} from 'react-native-reanimated'
|
||||||
|
|
||||||
import {isNative} from '#/platform/detection'
|
import {isNative} from '#/platform/detection'
|
||||||
|
|
||||||
@@ -7,6 +7,7 @@ export const PagerHeaderContext = React.createContext<{
|
|||||||
scrollY: SharedValue<number>
|
scrollY: SharedValue<number>
|
||||||
headerHeight: number
|
headerHeight: number
|
||||||
} | null>(null)
|
} | null>(null)
|
||||||
|
PagerHeaderContext.displayName = 'PagerHeaderContext'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Passes information about the scroll position and header height down via
|
* Passes information about the scroll position and header height down via
|
||||||
|
|||||||
Reference in New Issue
Block a user