Bluesky app fork with some witchin' additions 💫 witchsky.app
bluesky fork client
117
fork

Configure Feed

Select the types of activity you want to include in your feed.

chore: fix linting errors

+761 -519
+15 -15
src/components/ProfileHoverCard/index.web.tsx
··· 1 - import {memo, useCallback, useEffect, useMemo, useReducer, useRef} from 'react' 1 + import {memo, useEffect, useMemo, useReducer, useRef} from 'react' 2 2 import {View} from 'react-native' 3 3 import { 4 4 type AppBskyActorDefs, ··· 275 275 276 276 const prefetchProfileQuery = usePrefetchProfileQuery() 277 277 const prefetchedProfile = useRef(false) 278 - const prefetchIfNeeded = useCallback(async () => { 278 + const prefetchIfNeeded = async () => { 279 279 if (!prefetchedProfile.current) { 280 280 prefetchedProfile.current = true 281 281 prefetchProfileQuery(props.did) 282 282 } 283 - }, [prefetchProfileQuery, props.did]) 283 + } 284 284 285 285 const didFireHover = useRef(false) 286 - const onPointerMoveTarget = useCallback(() => { 286 + const onPointerMoveTarget = () => { 287 287 prefetchIfNeeded() 288 288 // Conceptually we want something like onPointerEnter, 289 289 // but we want to ignore entering only due to scrolling. ··· 292 292 didFireHover.current = true 293 293 dispatch('hovered-target') 294 294 } 295 - }, [prefetchIfNeeded]) 295 + } 296 296 297 - const onPointerLeaveTarget = useCallback(() => { 297 + const onPointerLeaveTarget = () => { 298 298 didFireHover.current = false 299 299 dispatch('unhovered-target') 300 - }, []) 300 + } 301 301 302 - const onPointerEnterCard = useCallback(() => { 302 + const onPointerEnterCard = () => { 303 303 dispatch('hovered-card') 304 - }, []) 304 + } 305 305 306 - const onPointerLeaveCard = useCallback(() => { 306 + const onPointerLeaveCard = () => { 307 307 dispatch('unhovered-card') 308 - }, []) 308 + } 309 309 310 - const onPress = useCallback(() => { 310 + const onPress = () => { 311 311 dispatch('pressed') 312 - }, []) 312 + } 313 313 314 314 const isVisible = 315 315 currentState.stage === 'showing' || ··· 368 368 369 369 const status = useActorStatus(data) 370 370 371 - const onPressOpenProfile = useCallback(() => { 371 + const onPressOpenProfile = () => { 372 372 if (!status.isActive || !data) return 373 373 hide() 374 374 navigation.push('Profile', { 375 375 name: data.handle, 376 376 }) 377 - }, [hide, navigation, status, data]) 377 + } 378 378 379 379 return ( 380 380 <View
+5 -9
src/components/RichTextTag.tsx
··· 1 - import {useMemo} from 'react' 2 1 import {type StyleProp, Text as RNText, type TextStyle} from 'react-native' 3 2 import {msg} from '@lingui/core/macro' 4 3 import {useLingui} from '@lingui/react' ··· 62 61 optimisticUpsert?.find( 63 62 m => m.value === tag && m.targets.includes('tag'), 64 63 )) && 65 - !optimisticRemove?.find(m => m?.value === tag), 64 + !optimisticRemove?.find(m => m?.value === tag), 66 65 ) 67 66 68 67 /* 69 68 * Mute word records that exactly match the tag in question. 70 69 */ 71 - const removeableMuteWords = useMemo(() => { 72 - return ( 73 - preferences?.moderationPrefs.mutedWords?.filter(word => { 74 - return word.value === tag 75 - }) || [] 76 - ) 77 - }, [tag, preferences?.moderationPrefs?.mutedWords]) 70 + const removeableMuteWords = 71 + preferences?.moderationPrefs.mutedWords?.filter(word => { 72 + return word.value === tag 73 + }) || [] 78 74 79 75 return ( 80 76 <Menu.Root>
+2 -2
src/components/dialogs/PostInteractionSettingsDialog.tsx
··· 352 352 v => v.type === 'list', 353 353 ).length 354 354 355 - const toggleGroupValues = useMemo(() => { 355 + const toggleGroupValues = (() => { 356 356 const values: string[] = [] 357 357 for (const setting of threadgateAllowUISettings) { 358 358 switch (setting.type) { ··· 377 377 } 378 378 } 379 379 return values 380 - }, [threadgateAllowUISettings]) 380 + })() 381 381 382 382 const toggleGroupOnChange = (values: string[]) => { 383 383 const settings: ThreadgateAllowUISetting[] = []
+20 -11
src/components/forms/TextField.tsx
··· 1 - import React, {createContext, useContext, useMemo, useRef} from 'react' 1 + import { 2 + Children, 3 + type ComponentType, 4 + createContext, 5 + type ForwardedRef, 6 + isValidElement, 7 + type PropsWithChildren, 8 + type RefObject, 9 + useContext, 10 + useMemo, 11 + useRef, 12 + } from 'react' 2 13 import { 3 14 type AccessibilityProps, 4 15 StyleSheet, ··· 29 40 import {IS_WEB} from '#/env' 30 41 31 42 const Context = createContext<{ 32 - inputRef: React.RefObject<TextInput | null> | null 43 + inputRef: RefObject<TextInput | null> | null 33 44 isInvalid: boolean 34 45 hovered: boolean 35 46 onHoverIn: () => void ··· 49 60 }) 50 61 Context.displayName = 'TextFieldContext' 51 62 52 - export type RootProps = React.PropsWithChildren< 53 - {isInvalid?: boolean} & TextStyleProp 54 - > 63 + export type RootProps = PropsWithChildren<{isInvalid?: boolean} & TextStyleProp> 55 64 56 65 export function Root({children, isInvalid = false, style}: RootProps) { 57 66 const inputRef = useRef<TextInput>(null) ··· 88 97 // Check if any child has multiline prop 89 98 const hasMultiline = useMemo(() => { 90 99 let found = false 91 - React.Children.forEach(children, child => { 100 + Children.forEach(children, child => { 92 101 if ( 93 - React.isValidElement(child) && 102 + isValidElement(child) && 94 103 (child.props as {multiline?: boolean})?.multiline 95 104 ) { 96 105 found = true ··· 172 181 value?: string 173 182 onChangeText?: (value: string) => void 174 183 isInvalid?: boolean 175 - inputRef?: React.RefObject<TextInput | null> | React.ForwardedRef<TextInput> 184 + inputRef?: RefObject<TextInput | null> | ForwardedRef<TextInput> 176 185 /** 177 186 * Note: this currently falls back to the label if not specified. However, 178 187 * most new designs have no placeholder. We should eventually remove this fallback ··· 324 333 export function LabelText({ 325 334 nativeID, 326 335 children, 327 - }: React.PropsWithChildren<{nativeID?: string}>) { 336 + }: PropsWithChildren<{nativeID?: string}>) { 328 337 const t = useTheme() 329 338 return ( 330 339 <Text ··· 335 344 ) 336 345 } 337 346 338 - export function Icon({icon: Comp}: {icon: React.ComponentType<SVGIconProps>}) { 347 + export function Icon({icon: Comp}: {icon: ComponentType<SVGIconProps>}) { 339 348 const t = useTheme() 340 349 const ctx = useContext(Context) 341 350 const {hover, focus, errorHover, errorFocus} = useMemo(() => { ··· 389 398 label, 390 399 accessibilityHint, 391 400 style, 392 - }: React.PropsWithChildren< 401 + }: PropsWithChildren< 393 402 TextStyleProp & { 394 403 label: string 395 404 accessibilityHint?: AccessibilityProps['accessibilityHint']
+3 -12
src/components/moderation/ContentHider.tsx
··· 1 - import {useMemo, useState} from 'react' 1 + import {useState} from 'react' 2 2 import { 3 3 LayoutAnimation, 4 4 type StyleProp, ··· 88 88 const blur = modui?.blurs[0] 89 89 const desc = useModerationCauseDescription(blur) 90 90 91 - const labelName = useMemo(() => { 91 + const labelName = (() => { 92 92 if (!modui?.blurs || !blur) { 93 93 return undefined 94 94 } ··· 137 137 return desc.name 138 138 } 139 139 return [...new Set(selfBlurNames)].join(', ') 140 - }, [ 141 - _, 142 - modui?.blurs, 143 - blur, 144 - desc.name, 145 - desc.isSubjectAccount, 146 - labelDefs, 147 - i18n.locale, 148 - globalLabelStrings, 149 - ]) 140 + })() 150 141 151 142 return ( 152 143 <View testID={testID} style={[a.overflow_hidden, style]}>
-1
src/screens/Login/index.tsx
··· 23 23 import {atoms as a, native} from '#/alf' 24 24 import {ScreenTransition} from '#/components/ScreenTransition' 25 25 import {useAnalytics} from '#/analytics' 26 - import {IS_WEB} from '#/env' 27 26 import {ChooseAccountForm} from './ChooseAccountForm' 28 27 import * as AuthLayout from './components/AuthLayout' 29 28 import {AuthLayoutNavigationContext} from './components/AuthLayout/context'
+2 -2
src/screens/PostThread/index.tsx
··· 73 73 * One query to rule them all 74 74 */ 75 75 const thread = usePostThread({anchor: uri}) 76 - const {anchor, hasParents} = useMemo(() => { 76 + const {anchor, hasParents} = (() => { 77 77 let hasParents = false 78 78 for (const item of thread.data.items) { 79 79 if (item.type === 'threadPost' && item.depth === 0) { ··· 82 82 hasParents = true 83 83 } 84 84 return {hasParents} 85 - }, [thread.data.items]) 85 + })() 86 86 87 87 // Track post:view event when anchor post is viewed 88 88 const seenPostUriRef = useRef<string | null>(null)
+8 -3
src/state/gallery.ts
··· 13 13 } from 'expo-image-manipulator' 14 14 import {type BlobRef} from '@atproto/api' 15 15 import {transformExif} from '@uwx/exif-be-gone-web' 16 - import {toByteArray, fromByteArray} from 'base64-js' 16 + import {fromByteArray, toByteArray} from 'base64-js' 17 17 import {nanoid} from 'nanoid/non-secure' 18 18 19 19 import {POST_IMG_MAX} from '#/lib/constants' ··· 437 437 }) 438 438 } 439 439 440 - function arrayBufferToDataUri(buffer: Uint8Array | ArrayBufferLike, mime: string): string { 441 - const base64 = fromByteArray(buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer)) 440 + function arrayBufferToDataUri( 441 + buffer: Uint8Array | ArrayBufferLike, 442 + mime: string, 443 + ): string { 444 + const base64 = fromByteArray( 445 + buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer), 446 + ) 442 447 return `data:${mime};base64,${base64}` 443 448 } 444 449
+2 -1
src/state/preferences/alt-text-required.tsx
··· 5 5 useEffect, 6 6 useState, 7 7 } from 'react' 8 + import type {PropsWithChildren} from 'react' 8 9 9 10 import * as persisted from '#/state/persisted' 10 11 ··· 20 21 ) 21 22 setContext.displayName = 'AltTextRequiredSetContext' 22 23 23 - export function Provider({children}: React.PropsWithChildren<{}>) { 24 + export function Provider({children}: PropsWithChildren<{}>) { 24 25 const [state, setState] = useState(persisted.get('requireAltTextEnabled')) 25 26 26 27 const setStateWrapped = useCallback(
+2 -1
src/state/preferences/auto-like-on-repost.tsx
··· 5 5 useEffect, 6 6 useState, 7 7 } from 'react' 8 + import type {PropsWithChildren} from 'react' 8 9 9 10 import * as persisted from '#/state/persisted' 10 11 ··· 20 21 ) 21 22 setContext.displayName = 'AutoLikeOnRepostStateContext' 22 23 23 - export function Provider({children}: React.PropsWithChildren<{}>) { 24 + export function Provider({children}: PropsWithChildren<{}>) { 24 25 const [state, setState] = useState(persisted.get('autoLikeOnRepost')) 25 26 26 27 const setStateWrapped = useCallback(
+2 -1
src/state/preferences/autoplay.tsx
··· 5 5 useEffect, 6 6 useState, 7 7 } from 'react' 8 + import type {PropsWithChildren} from 'react' 8 9 9 10 import * as persisted from '#/state/persisted' 10 11 ··· 18 19 const setContext = createContext<SetContext>((_: boolean) => {}) 19 20 setContext.displayName = 'AutoplaySetContext' 20 21 21 - export function Provider({children}: {children: React.ReactNode}) { 22 + export function Provider({children}: PropsWithChildren<{}>) { 22 23 const [state, setState] = useState(Boolean(persisted.get('disableAutoplay'))) 23 24 24 25 const setStateWrapped = useCallback(
+16 -11
src/state/preferences/constellation-enabled.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + useCallback, 4 + useContext, 5 + useEffect, 6 + useState, 7 + } from 'react' 8 + import type {PropsWithChildren} from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['constellationEnabled'] 6 13 type SetContext = (v: persisted.Schema['constellationEnabled']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 15 + const stateContext = createContext<StateContext>( 9 16 persisted.defaults.constellationEnabled, 10 17 ) 11 - const setContext = React.createContext<SetContext>( 18 + const setContext = createContext<SetContext>( 12 19 (_: persisted.Schema['constellationEnabled']) => {}, 13 20 ) 14 21 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState( 17 - persisted.get('constellationEnabled'), 18 - ) 22 + export function Provider({children}: PropsWithChildren<{}>) { 23 + const [state, setState] = useState(persisted.get('constellationEnabled')) 19 24 20 - const setStateWrapped = React.useCallback( 25 + const setStateWrapped = useCallback( 21 26 (constellationEnabled: persisted.Schema['constellationEnabled']) => { 22 27 setState(constellationEnabled) 23 28 persisted.write('constellationEnabled', constellationEnabled) ··· 25 30 [setState], 26 31 ) 27 32 28 - React.useEffect(() => { 33 + useEffect(() => { 29 34 return persisted.onUpdate( 30 35 'constellationEnabled', 31 36 nextConstellationEnabled => { ··· 44 49 } 45 50 46 51 export function useConstellationEnabled() { 47 - return React.useContext(stateContext) 52 + return useContext(stateContext) 48 53 } 49 54 50 55 export function useSetConstellationEnabled() { 51 - return React.useContext(setContext) 56 + return useContext(setContext) 52 57 }
+16 -13
src/state/preferences/constellation-instance.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + useCallback, 4 + useContext, 5 + useEffect, 6 + useState, 7 + } from 'react' 8 + import type {PropsWithChildren} from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['constellationInstance'] 6 13 type SetContext = (v: persisted.Schema['constellationInstance']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 15 + const stateContext = createContext<StateContext>( 9 16 persisted.defaults.constellationInstance, 10 17 ) 11 - const setContext = React.createContext<SetContext>( 18 + const setContext = createContext<SetContext>( 12 19 (_: persisted.Schema['constellationInstance']) => {}, 13 20 ) 14 21 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState( 17 - persisted.get('constellationInstance'), 18 - ) 22 + export function Provider({children}: PropsWithChildren<{}>) { 23 + const [state, setState] = useState(persisted.get('constellationInstance')) 19 24 20 - const setStateWrapped = React.useCallback( 25 + const setStateWrapped = useCallback( 21 26 (constellationInstance: persisted.Schema['constellationInstance']) => { 22 27 setState(constellationInstance) 23 28 persisted.write('constellationInstance', constellationInstance) ··· 25 30 [setState], 26 31 ) 27 32 28 - React.useEffect(() => { 33 + useEffect(() => { 29 34 return persisted.onUpdate( 30 35 'constellationInstance', 31 36 nextConstellationInstance => { ··· 44 49 } 45 50 46 51 export function useConstellationInstance() { 47 - return ( 48 - React.useContext(stateContext) ?? persisted.defaults.constellationInstance! 49 - ) 52 + return useContext(stateContext) ?? persisted.defaults.constellationInstance! 50 53 } 51 54 52 55 export function useSetConstellationInstance() { 53 - return React.useContext(setContext) 56 + return useContext(setContext) 54 57 }
+2 -2
src/state/preferences/custom-appview-did.tsx
··· 1 - import React from 'react' 1 + import {useCallback} from 'react' 2 2 import {reloadAppAsync} from 'expo' 3 3 import {isDid} from '@atproto/api' 4 4 ··· 17 17 export function useSetCustomAppViewDid() { 18 18 const [, setCustomAppViewDid] = useCustomAppViewDid() 19 19 20 - return React.useCallback( 20 + return useCallback( 21 21 (customAppViewDid: string | undefined) => { 22 22 setCustomAppViewDid(customAppViewDid) 23 23
+19 -11
src/state/preferences/deer-verification.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useMemo, 8 + useState, 9 + } from 'react' 2 10 3 11 import * as persisted from '#/state/persisted' 4 12 5 13 type StateContext = persisted.Schema['deerVerification'] 6 14 type SetContext = (v: persisted.Schema['deerVerification']) => void 7 15 8 - const stateContext = React.createContext<StateContext>( 16 + const stateContext = createContext<StateContext>( 9 17 persisted.defaults.deerVerification, 10 18 ) 11 - const setContext = React.createContext<SetContext>( 19 + const setContext = createContext<SetContext>( 12 20 (_: persisted.Schema['deerVerification']) => {}, 13 21 ) 14 22 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState(persisted.get('deerVerification')) 23 + export function Provider({children}: PropsWithChildren<{}>) { 24 + const [state, setState] = useState(persisted.get('deerVerification')) 17 25 18 - const setStateWrapped = React.useCallback( 26 + const setStateWrapped = useCallback( 19 27 (deerVerification: persisted.Schema['deerVerification']) => { 20 28 setState(deerVerification) 21 29 persisted.write('deerVerification', deerVerification) ··· 23 31 [setState], 24 32 ) 25 33 26 - React.useEffect(() => { 34 + useEffect(() => { 27 35 return persisted.onUpdate('deerVerification', nextDeerVerification => { 28 36 setState(nextDeerVerification) 29 37 }) ··· 39 47 } 40 48 41 49 export function useDeerVerification() { 42 - return React.useContext(stateContext) ?? persisted.defaults.deerVerification! 50 + return useContext(stateContext) ?? persisted.defaults.deerVerification! 43 51 } 44 52 45 53 export function useDeerVerificationEnabled() { ··· 57 65 } 58 66 59 67 export function useSetDeerVerification() { 60 - return React.useContext(setContext) 68 + return useContext(setContext) 61 69 } 62 70 63 71 export function useSetDeerVerificationEnabled() { 64 72 const deerVerification = useDeerVerification() 65 73 const setDeerVerification = useSetDeerVerification() 66 74 67 - return React.useMemo( 75 + return useMemo( 68 76 () => (enabled: boolean) => 69 77 setDeerVerification({...deerVerification, enabled}), 70 78 [deerVerification, setDeerVerification], ··· 75 83 const deerVerification = useDeerVerification() 76 84 const setDeerVerification = useSetDeerVerification() 77 85 78 - return React.useMemo( 86 + return useMemo( 79 87 () => ({ 80 88 add: (add: string) => { 81 89 const trusted = new Set(deerVerification.trusted)
+16 -9
src/state/preferences/direct-fetch-records.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['directFetchRecords'] 6 13 type SetContext = (v: persisted.Schema['directFetchRecords']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 15 + const stateContext = createContext<StateContext>( 9 16 persisted.defaults.directFetchRecords, 10 17 ) 11 - const setContext = React.createContext<SetContext>( 18 + const setContext = createContext<SetContext>( 12 19 (_: persisted.Schema['directFetchRecords']) => {}, 13 20 ) 14 21 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState(persisted.get('directFetchRecords')) 22 + export function Provider({children}: PropsWithChildren<{}>) { 23 + const [state, setState] = useState(persisted.get('directFetchRecords')) 17 24 18 - const setStateWrapped = React.useCallback( 25 + const setStateWrapped = useCallback( 19 26 (directFetchRecords: persisted.Schema['directFetchRecords']) => { 20 27 setState(directFetchRecords) 21 28 persisted.write('directFetchRecords', directFetchRecords) ··· 23 30 [setState], 24 31 ) 25 32 26 - React.useEffect(() => { 33 + useEffect(() => { 27 34 return persisted.onUpdate('directFetchRecords', nextDirectFetchRecords => { 28 35 setState(nextDirectFetchRecords) 29 36 }) ··· 39 46 } 40 47 41 48 export function useDirectFetchRecords() { 42 - return React.useContext(stateContext) 49 + return useContext(stateContext) 43 50 } 44 51 45 52 export function useSetDirectFetchRecords() { 46 - return React.useContext(setContext) 53 + return useContext(setContext) 47 54 }
+16 -11
src/state/preferences/disable-composer-prompt.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['disableComposerPrompt']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.disableComposerPrompt, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['disableComposerPrompt']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState( 20 - persisted.get('disableComposerPrompt'), 21 - ) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('disableComposerPrompt')) 22 27 23 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 24 29 (disableComposerPrompt: persisted.Schema['disableComposerPrompt']) => { 25 30 setState(disableComposerPrompt) 26 31 persisted.write('disableComposerPrompt', disableComposerPrompt) ··· 28 33 [setState], 29 34 ) 30 35 31 - React.useEffect(() => { 36 + useEffect(() => { 32 37 return persisted.onUpdate( 33 38 'disableComposerPrompt', 34 39 nextDisableComposerPrompt => { ··· 47 52 } 48 53 49 54 export function useDisableComposerPrompt() { 50 - return React.useContext(stateContext) 55 + return useContext(stateContext) 51 56 } 52 57 53 58 export function useSetDisableComposerPrompt() { 54 - return React.useContext(setContext) 59 + return useContext(setContext) 55 60 }
+16 -11
src/state/preferences/disable-followed-by-metrics.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['disableFollowedByMetrics']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.disableFollowedByMetrics, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['disableFollowedByMetrics']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState( 20 - persisted.get('disableFollowedByMetrics'), 21 - ) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('disableFollowedByMetrics')) 22 27 23 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 24 29 (value: persisted.Schema['disableFollowedByMetrics']) => { 25 30 setState(value) 26 31 persisted.write('disableFollowedByMetrics', value) ··· 28 33 [setState], 29 34 ) 30 35 31 - React.useEffect(() => { 36 + useEffect(() => { 32 37 return persisted.onUpdate('disableFollowedByMetrics', next => { 33 38 setState(next) 34 39 }) ··· 44 49 } 45 50 46 51 export function useDisableFollowedByMetrics() { 47 - return React.useContext(stateContext) 52 + return useContext(stateContext) 48 53 } 49 54 50 55 export function useSetDisableFollowedByMetrics() { 51 - return React.useContext(setContext) 56 + return useContext(setContext) 52 57 }
+16 -11
src/state/preferences/disable-followers-metrics.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['disableFollowersMetrics']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.disableFollowersMetrics, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['disableFollowersMetrics']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState( 20 - persisted.get('disableFollowersMetrics'), 21 - ) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('disableFollowersMetrics')) 22 27 23 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 24 29 (value: persisted.Schema['disableFollowersMetrics']) => { 25 30 setState(value) 26 31 persisted.write('disableFollowersMetrics', value) ··· 28 33 [setState], 29 34 ) 30 35 31 - React.useEffect(() => { 36 + useEffect(() => { 32 37 return persisted.onUpdate('disableFollowersMetrics', next => { 33 38 setState(next) 34 39 }) ··· 44 49 } 45 50 46 51 export function useDisableFollowersMetrics() { 47 - return React.useContext(stateContext) 52 + return useContext(stateContext) 48 53 } 49 54 50 55 export function useSetDisableFollowersMetrics() { 51 - return React.useContext(setContext) 56 + return useContext(setContext) 52 57 }
+16 -11
src/state/preferences/disable-following-metrics.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['disableFollowingMetrics']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.disableFollowingMetrics, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['disableFollowingMetrics']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState( 20 - persisted.get('disableFollowingMetrics'), 21 - ) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('disableFollowingMetrics')) 22 27 23 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 24 29 (value: persisted.Schema['disableFollowingMetrics']) => { 25 30 setState(value) 26 31 persisted.write('disableFollowingMetrics', value) ··· 28 33 [setState], 29 34 ) 30 35 31 - React.useEffect(() => { 36 + useEffect(() => { 32 37 return persisted.onUpdate('disableFollowingMetrics', next => { 33 38 setState(next) 34 39 }) ··· 44 49 } 45 50 46 51 export function useDisableFollowingMetrics() { 47 - return React.useContext(stateContext) 52 + return useContext(stateContext) 48 53 } 49 54 50 55 export function useSetDisableFollowingMetrics() { 51 - return React.useContext(setContext) 56 + return useContext(setContext) 52 57 }
+2 -1
src/state/preferences/disable-haptics.tsx
··· 5 5 useEffect, 6 6 useState, 7 7 } from 'react' 8 + import type {PropsWithChildren} from 'react' 8 9 9 10 import * as persisted from '#/state/persisted' 10 11 ··· 18 19 const setContext = createContext<SetContext>((_: boolean) => {}) 19 20 setContext.displayName = 'DisableHapticsSetContext' 20 21 21 - export function Provider({children}: {children: React.ReactNode}) { 22 + export function Provider({children}: PropsWithChildren<{}>) { 22 23 const [state, setState] = useState(Boolean(persisted.get('disableHaptics'))) 23 24 24 25 const setStateWrapped = useCallback(
+16 -9
src/state/preferences/disable-likes-metrics.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['disableLikesMetrics']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.disableLikesMetrics, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['disableLikesMetrics']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState(persisted.get('disableLikesMetrics')) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('disableLikesMetrics')) 20 27 21 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 22 29 (value: persisted.Schema['disableLikesMetrics']) => { 23 30 setState(value) 24 31 persisted.write('disableLikesMetrics', value) ··· 26 33 [setState], 27 34 ) 28 35 29 - React.useEffect(() => { 36 + useEffect(() => { 30 37 return persisted.onUpdate('disableLikesMetrics', next => { 31 38 setState(next) 32 39 }) ··· 42 49 } 43 50 44 51 export function useDisableLikesMetrics() { 45 - return React.useContext(stateContext) 52 + return useContext(stateContext) 46 53 } 47 54 48 55 export function useSetDisableLikesMetrics() { 49 - return React.useContext(setContext) 56 + return useContext(setContext) 50 57 }
+16 -9
src/state/preferences/disable-posts-metrics.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['disablePostsMetrics']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.disablePostsMetrics, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['disablePostsMetrics']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState(persisted.get('disablePostsMetrics')) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('disablePostsMetrics')) 20 27 21 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 22 29 (value: persisted.Schema['disablePostsMetrics']) => { 23 30 setState(value) 24 31 persisted.write('disablePostsMetrics', value) ··· 26 33 [setState], 27 34 ) 28 35 29 - React.useEffect(() => { 36 + useEffect(() => { 30 37 return persisted.onUpdate('disablePostsMetrics', next => { 31 38 setState(next) 32 39 }) ··· 42 49 } 43 50 44 51 export function useDisablePostsMetrics() { 45 - return React.useContext(stateContext) 52 + return useContext(stateContext) 46 53 } 47 54 48 55 export function useSetDisablePostsMetrics() { 49 - return React.useContext(setContext) 56 + return useContext(setContext) 50 57 }
+16 -11
src/state/preferences/disable-quotes-metrics.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['disableQuotesMetrics']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.disableQuotesMetrics, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['disableQuotesMetrics']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState( 20 - persisted.get('disableQuotesMetrics'), 21 - ) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('disableQuotesMetrics')) 22 27 23 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 24 29 (value: persisted.Schema['disableQuotesMetrics']) => { 25 30 setState(value) 26 31 persisted.write('disableQuotesMetrics', value) ··· 28 33 [setState], 29 34 ) 30 35 31 - React.useEffect(() => { 36 + useEffect(() => { 32 37 return persisted.onUpdate('disableQuotesMetrics', next => { 33 38 setState(next) 34 39 }) ··· 44 49 } 45 50 46 51 export function useDisableQuotesMetrics() { 47 - return React.useContext(stateContext) 52 + return useContext(stateContext) 48 53 } 49 54 50 55 export function useSetDisableQuotesMetrics() { 51 - return React.useContext(setContext) 56 + return useContext(setContext) 52 57 }
+16 -9
src/state/preferences/disable-reply-metrics.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['disableReplyMetrics']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.disableReplyMetrics, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['disableReplyMetrics']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState(persisted.get('disableReplyMetrics')) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('disableReplyMetrics')) 20 27 21 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 22 29 (value: persisted.Schema['disableReplyMetrics']) => { 23 30 setState(value) 24 31 persisted.write('disableReplyMetrics', value) ··· 26 33 [setState], 27 34 ) 28 35 29 - React.useEffect(() => { 36 + useEffect(() => { 30 37 return persisted.onUpdate('disableReplyMetrics', next => { 31 38 setState(next) 32 39 }) ··· 42 49 } 43 50 44 51 export function useDisableReplyMetrics() { 45 - return React.useContext(stateContext) 52 + return useContext(stateContext) 46 53 } 47 54 48 55 export function useSetDisableReplyMetrics() { 49 - return React.useContext(setContext) 56 + return useContext(setContext) 50 57 }
+16 -11
src/state/preferences/disable-reposts-metrics.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['disableRepostsMetrics']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.disableRepostsMetrics, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['disableRepostsMetrics']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState( 20 - persisted.get('disableRepostsMetrics'), 21 - ) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('disableRepostsMetrics')) 22 27 23 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 24 29 (value: persisted.Schema['disableRepostsMetrics']) => { 25 30 setState(value) 26 31 persisted.write('disableRepostsMetrics', value) ··· 28 33 [setState], 29 34 ) 30 35 31 - React.useEffect(() => { 36 + useEffect(() => { 32 37 return persisted.onUpdate('disableRepostsMetrics', next => { 33 38 setState(next) 34 39 }) ··· 44 49 } 45 50 46 51 export function useDisableRepostsMetrics() { 47 - return React.useContext(stateContext) 52 + return useContext(stateContext) 48 53 } 49 54 50 55 export function useSetDisableRepostsMetrics() { 51 - return React.useContext(setContext) 56 + return useContext(setContext) 52 57 }
+16 -9
src/state/preferences/disable-saves-metrics.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['disableSavesMetrics']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.disableSavesMetrics, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['disableSavesMetrics']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState(persisted.get('disableSavesMetrics')) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('disableSavesMetrics')) 20 27 21 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 22 29 (value: persisted.Schema['disableSavesMetrics']) => { 23 30 setState(value) 24 31 persisted.write('disableSavesMetrics', value) ··· 26 33 [setState], 27 34 ) 28 35 29 - React.useEffect(() => { 36 + useEffect(() => { 30 37 return persisted.onUpdate('disableSavesMetrics', next => { 31 38 setState(next) 32 39 }) ··· 42 49 } 43 50 44 51 export function useDisableSavesMetrics() { 45 - return React.useContext(stateContext) 52 + return useContext(stateContext) 46 53 } 47 54 48 55 export function useSetDisableSavesMetrics() { 49 - return React.useContext(setContext) 56 + return useContext(setContext) 50 57 }
+16 -9
src/state/preferences/disable-verify-email-reminder.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['disableVerifyEmailReminder']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.disableVerifyEmailReminder, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['disableVerifyEmailReminder']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState( 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState( 20 27 persisted.get('disableVerifyEmailReminder'), 21 28 ) 22 29 23 - const setStateWrapped = React.useCallback( 30 + const setStateWrapped = useCallback( 24 31 (value: persisted.Schema['disableVerifyEmailReminder']) => { 25 32 setState(value) 26 33 persisted.write('disableVerifyEmailReminder', value) ··· 28 35 [setState], 29 36 ) 30 37 31 - React.useEffect(() => { 38 + useEffect(() => { 32 39 return persisted.onUpdate('disableVerifyEmailReminder', next => { 33 40 setState(next) 34 41 }) ··· 44 51 } 45 52 46 53 export function useDisableVerifyEmailReminder() { 47 - return React.useContext(stateContext) 54 + return useContext(stateContext) 48 55 } 49 56 50 57 export function useSetDisableVerifyEmailReminder() { 51 - return React.useContext(setContext) 58 + return useContext(setContext) 52 59 }
+16 -9
src/state/preferences/disable-via-repost-notification.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['disableViaRepostNotification']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.disableViaRepostNotification, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['disableViaRepostNotification']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState( 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState( 20 27 persisted.get('disableViaRepostNotification'), 21 28 ) 22 29 23 - const setStateWrapped = React.useCallback( 30 + const setStateWrapped = useCallback( 24 31 (value: persisted.Schema['disableViaRepostNotification']) => { 25 32 setState(value) 26 33 persisted.write('disableViaRepostNotification', value) ··· 28 35 [setState], 29 36 ) 30 37 31 - React.useEffect(() => { 38 + useEffect(() => { 32 39 return persisted.onUpdate('disableViaRepostNotification', next => { 33 40 setState(next) 34 41 }) ··· 44 51 } 45 52 46 53 export function useDisableViaRepostNotification() { 47 - return React.useContext(stateContext) 54 + return useContext(stateContext) 48 55 } 49 56 50 57 export function useSetDisableViaRepostNotification() { 51 - return React.useContext(setContext) 58 + return useContext(setContext) 52 59 }
+16 -11
src/state/preferences/discover-context-enabled.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['discoverContextEnabled']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.discoverContextEnabled, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['discoverContextEnabled']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState( 20 - persisted.get('discoverContextEnabled'), 21 - ) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('discoverContextEnabled')) 22 27 23 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 24 29 (discoverContextEnabled: persisted.Schema['discoverContextEnabled']) => { 25 30 setState(discoverContextEnabled) 26 31 persisted.write('discoverContextEnabled', discoverContextEnabled) ··· 28 33 [setState], 29 34 ) 30 35 31 - React.useEffect(() => { 36 + useEffect(() => { 32 37 return persisted.onUpdate( 33 38 'discoverContextEnabled', 34 39 nextDiscoverContextEnabled => { ··· 47 52 } 48 53 49 54 export function useDiscoverContextEnabled() { 50 - return React.useContext(stateContext) 55 + return useContext(stateContext) 51 56 } 52 57 53 58 export function useSetDiscoverContextEnabled() { 54 - return React.useContext(setContext) 59 + return useContext(setContext) 55 60 }
+16 -9
src/state/preferences/enable-square-avatars.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['enableSquareAvatars']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.enableSquareAvatars, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['enableSquareAvatars']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState(persisted.get('enableSquareAvatars')) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('enableSquareAvatars')) 20 27 21 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 22 29 (value: persisted.Schema['enableSquareAvatars']) => { 23 30 setState(value) 24 31 persisted.write('enableSquareAvatars', value) ··· 26 33 [setState], 27 34 ) 28 35 29 - React.useEffect(() => { 36 + useEffect(() => { 30 37 return persisted.onUpdate('enableSquareAvatars', next => { 31 38 setState(next) 32 39 }) ··· 42 49 } 43 50 44 51 export function useEnableSquareAvatars() { 45 - return React.useContext(stateContext) 52 + return useContext(stateContext) 46 53 } 47 54 48 55 export function useSetEnableSquareAvatars() { 49 - return React.useContext(setContext) 56 + return useContext(setContext) 50 57 }
+16 -9
src/state/preferences/enable-square-buttons.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['enableSquareButtons']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.enableSquareButtons, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['enableSquareButtons']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState(persisted.get('enableSquareButtons')) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('enableSquareButtons')) 20 27 21 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 22 29 (value: persisted.Schema['enableSquareButtons']) => { 23 30 setState(value) 24 31 persisted.write('enableSquareButtons', value) ··· 26 33 [setState], 27 34 ) 28 35 29 - React.useEffect(() => { 36 + useEffect(() => { 30 37 return persisted.onUpdate('enableSquareButtons', next => { 31 38 setState(next) 32 39 }) ··· 42 49 } 43 50 44 51 export function useEnableSquareButtons() { 45 - return React.useContext(stateContext) 52 + return useContext(stateContext) 46 53 } 47 54 48 55 export function useSetEnableSquareButtons() { 49 - return React.useContext(setContext) 56 + return useContext(setContext) 50 57 }
+2 -1
src/state/preferences/external-embeds-prefs.tsx
··· 5 5 useEffect, 6 6 useState, 7 7 } from 'react' 8 + import type {PropsWithChildren} from 'react' 8 9 9 10 import {type EmbedPlayerSource} from '#/lib/strings/embed-player' 10 11 import * as persisted from '#/state/persisted' ··· 22 23 const setContext = createContext<SetContext>({} as SetContext) 23 24 setContext.displayName = 'ExternalEmbedsPrefsSetContext' 24 25 25 - export function Provider({children}: React.PropsWithChildren<{}>) { 26 + export function Provider({children}: PropsWithChildren<{}>) { 26 27 const [state, setState] = useState(persisted.get('externalEmbeds')) 27 28 28 29 const setStateWrapped = useCallback(
+16 -11
src/state/preferences/external-share-buttons.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['showExternalShareButtons'] 6 13 type SetContext = (v: persisted.Schema['showExternalShareButtons']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 15 + const stateContext = createContext<StateContext>( 9 16 persisted.defaults.showExternalShareButtons, 10 17 ) 11 - const setContext = React.createContext<SetContext>( 18 + const setContext = createContext<SetContext>( 12 19 (_: persisted.Schema['showExternalShareButtons']) => {}, 13 20 ) 14 21 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState( 17 - persisted.get('showExternalShareButtons'), 18 - ) 22 + export function Provider({children}: PropsWithChildren<{}>) { 23 + const [state, setState] = useState(persisted.get('showExternalShareButtons')) 19 24 20 - const setStateWrapped = React.useCallback( 25 + const setStateWrapped = useCallback( 21 26 ( 22 27 showExternalShareButtons: persisted.Schema['showExternalShareButtons'], 23 28 ) => { ··· 27 32 [setState], 28 33 ) 29 34 30 - React.useEffect(() => { 35 + useEffect(() => { 31 36 return persisted.onUpdate( 32 37 'showExternalShareButtons', 33 38 nextShowExternalShareButtons => { ··· 46 51 } 47 52 48 53 export function useShowExternalShareButtons() { 49 - return React.useContext(stateContext) 54 + return useContext(stateContext) 50 55 } 51 56 52 57 export function useSetShowExternalShareButtons() { 53 - return React.useContext(setContext) 58 + return useContext(setContext) 54 59 }
+16 -9
src/state/preferences/favicon-service.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['faviconService'] 6 13 type SetContext = (v: persisted.Schema['faviconService']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 15 + const stateContext = createContext<StateContext>( 9 16 persisted.defaults.faviconService, 10 17 ) 11 - const setContext = React.createContext<SetContext>( 18 + const setContext = createContext<SetContext>( 12 19 (_: persisted.Schema['faviconService']) => {}, 13 20 ) 14 21 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState(persisted.get('faviconService')) 22 + export function Provider({children}: PropsWithChildren<{}>) { 23 + const [state, setState] = useState(persisted.get('faviconService')) 17 24 18 - const setStateWrapped = React.useCallback( 25 + const setStateWrapped = useCallback( 19 26 (faviconService: persisted.Schema['faviconService']) => { 20 27 setState(faviconService) 21 28 persisted.write('faviconService', faviconService) ··· 23 30 [setState], 24 31 ) 25 32 26 - React.useEffect(() => { 33 + useEffect(() => { 27 34 return persisted.onUpdate('faviconService', next => { 28 35 setState(next) 29 36 }) ··· 39 46 } 40 47 41 48 export function useFaviconService() { 42 - return React.useContext(stateContext) ?? persisted.defaults.faviconService 49 + return useContext(stateContext) ?? persisted.defaults.faviconService 43 50 } 44 51 45 52 export function useSetFaviconService() { 46 - const setFaviconService = React.useContext(setContext) 53 + const setFaviconService = useContext(setContext) 47 54 return setFaviconService 48 55 }
+2 -1
src/state/preferences/hidden-posts.tsx
··· 6 6 useMemo, 7 7 useState, 8 8 } from 'react' 9 + import type {PropsWithChildren} from 'react' 9 10 10 11 import * as persisted from '#/state/persisted' 11 12 ··· 26 27 }) 27 28 apiContext.displayName = 'HiddenPostsApiContext' 28 29 29 - export function Provider({children}: React.PropsWithChildren<{}>) { 30 + export function Provider({children}: PropsWithChildren<{}>) { 30 31 const [state, setState] = useState(persisted.get('hiddenPosts')) 31 32 32 33 const setStateWrapped = useCallback(
+16 -9
src/state/preferences/hide-feeds-promo-tab.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['hideFeedsPromoTab']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.hideFeedsPromoTab, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['hideFeedsPromoTab']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState(persisted.get('hideFeedsPromoTab')) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('hideFeedsPromoTab')) 20 27 21 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 22 29 (value: persisted.Schema['hideFeedsPromoTab']) => { 23 30 setState(value) 24 31 persisted.write('hideFeedsPromoTab', value) ··· 26 33 [setState], 27 34 ) 28 35 29 - React.useEffect(() => { 36 + useEffect(() => { 30 37 return persisted.onUpdate('hideFeedsPromoTab', next => { 31 38 setState(next) 32 39 }) ··· 42 49 } 43 50 44 51 export function useHideFeedsPromoTab() { 45 - return React.useContext(stateContext) 52 + return useContext(stateContext) 46 53 } 47 54 48 55 export function useSetHideFeedsPromoTab() { 49 - return React.useContext(setContext) 56 + return useContext(setContext) 50 57 }
+16 -11
src/state/preferences/hide-similar-accounts-recommendations.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 8 15 // Same setter signature used across other preference modules 9 16 type SetContext = (v: persisted.Schema['hideSimilarAccountsRecomm']) => void 10 17 11 - const stateContext = React.createContext<StateContext>( 18 + const stateContext = createContext<StateContext>( 12 19 persisted.defaults.hideSimilarAccountsRecomm, 13 20 ) 14 - const setContext = React.createContext<SetContext>( 21 + const setContext = createContext<SetContext>( 15 22 (_: persisted.Schema['hideSimilarAccountsRecomm']) => {}, 16 23 ) 17 24 18 - export function Provider({children}: React.PropsWithChildren<{}>) { 19 - const [state, setState] = React.useState( 20 - persisted.get('hideSimilarAccountsRecomm'), 21 - ) 25 + export function Provider({children}: PropsWithChildren<{}>) { 26 + const [state, setState] = useState(persisted.get('hideSimilarAccountsRecomm')) 22 27 23 - const setStateWrapped = React.useCallback( 28 + const setStateWrapped = useCallback( 24 29 (value: persisted.Schema['hideSimilarAccountsRecomm']) => { 25 30 setState(value) 26 31 persisted.write('hideSimilarAccountsRecomm', value) ··· 28 33 [setState], 29 34 ) 30 35 31 - React.useEffect(() => { 36 + useEffect(() => { 32 37 return persisted.onUpdate('hideSimilarAccountsRecomm', next => { 33 38 setState(next) 34 39 }) ··· 44 49 } 45 50 46 51 export function useHideSimilarAccountsRecomm() { 47 - return React.useContext(stateContext) 52 + return useContext(stateContext) 48 53 } 49 54 50 55 export function useSetHideSimilarAccountsRecomm() { 51 - return React.useContext(setContext) 56 + return useContext(setContext) 52 57 }
+16 -13
src/state/preferences/hide-unreplyable-posts.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['hideUnreplyablePosts'] 6 13 type SetContext = (v: persisted.Schema['hideUnreplyablePosts']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 15 + const stateContext = createContext<StateContext>( 9 16 persisted.defaults.hideUnreplyablePosts, 10 17 ) 11 - const setContext = React.createContext<SetContext>( 18 + const setContext = createContext<SetContext>( 12 19 (_: persisted.Schema['hideUnreplyablePosts']) => {}, 13 20 ) 14 21 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState( 17 - persisted.get('hideUnreplyablePosts'), 18 - ) 22 + export function Provider({children}: PropsWithChildren<{}>) { 23 + const [state, setState] = useState(persisted.get('hideUnreplyablePosts')) 19 24 20 - const setStateWrapped = React.useCallback( 25 + const setStateWrapped = useCallback( 21 26 (hideUnreplyablePosts: persisted.Schema['hideUnreplyablePosts']) => { 22 27 setState(hideUnreplyablePosts) 23 28 persisted.write('hideUnreplyablePosts', hideUnreplyablePosts) ··· 25 30 [setState], 26 31 ) 27 32 28 - React.useEffect(() => { 33 + useEffect(() => { 29 34 return persisted.onUpdate('hideUnreplyablePosts', nextValue => { 30 35 setState(nextValue) 31 36 }) ··· 41 46 } 42 47 43 48 export function useHideUnreplyablePosts() { 44 - return ( 45 - React.useContext(stateContext) ?? persisted.defaults.hideUnreplyablePosts 46 - ) 49 + return useContext(stateContext) ?? persisted.defaults.hideUnreplyablePosts 47 50 } 48 51 49 52 export function useSetHideUnreplyablePosts() { 50 - return React.useContext(setContext) 53 + return useContext(setContext) 51 54 }
+16 -9
src/state/preferences/high-quality-images.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['highQualityImages'] 6 13 type SetContext = (v: persisted.Schema['highQualityImages']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 15 + const stateContext = createContext<StateContext>( 9 16 persisted.defaults.highQualityImages, 10 17 ) 11 - const setContext = React.createContext<SetContext>( 18 + const setContext = createContext<SetContext>( 12 19 (_: persisted.Schema['highQualityImages']) => {}, 13 20 ) 14 21 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState(persisted.get('highQualityImages')) 22 + export function Provider({children}: PropsWithChildren<{}>) { 23 + const [state, setState] = useState(persisted.get('highQualityImages')) 17 24 18 - const setStateWrapped = React.useCallback( 25 + const setStateWrapped = useCallback( 19 26 (highQualityImages: persisted.Schema['highQualityImages']) => { 20 27 setState(highQualityImages) 21 28 persisted.write('highQualityImages', highQualityImages) ··· 23 30 [setState], 24 31 ) 25 32 26 - React.useEffect(() => { 33 + useEffect(() => { 27 34 return persisted.onUpdate('highQualityImages', nextHighQualityImages => { 28 35 setState(nextHighQualityImages) 29 36 }) ··· 39 46 } 40 47 41 48 export function useHighQualityImages() { 42 - return React.useContext(stateContext) 49 + return useContext(stateContext) 43 50 } 44 51 45 52 export function useSetHighQualityImages() { 46 - return React.useContext(setContext) 53 + return useContext(setContext) 47 54 } 48 55 49 56 // This is a little weird to have here imo but it works I guess
+16 -9
src/state/preferences/image-cdn-host.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['imageCdnHost'] 6 13 type SetContext = (v: persisted.Schema['imageCdnHost']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 15 + const stateContext = createContext<StateContext>( 9 16 persisted.defaults.imageCdnHost, 10 17 ) 11 - const setContext = React.createContext<SetContext>( 18 + const setContext = createContext<SetContext>( 12 19 (_: persisted.Schema['imageCdnHost']) => {}, 13 20 ) 14 21 ··· 16 23 persisted.defaults.imageCdnHost ?? '', 17 24 ) 18 25 19 - export function Provider({children}: React.PropsWithChildren<{}>) { 20 - const [state, setState] = React.useState(persisted.get('imageCdnHost')) 26 + export function Provider({children}: PropsWithChildren<{}>) { 27 + const [state, setState] = useState(persisted.get('imageCdnHost')) 21 28 22 - const setStateWrapped = React.useCallback( 29 + const setStateWrapped = useCallback( 23 30 (imageCdnHost: persisted.Schema['imageCdnHost']) => { 24 31 setState(imageCdnHost) 25 32 persisted.write('imageCdnHost', imageCdnHost) ··· 27 34 [setState], 28 35 ) 29 36 30 - React.useEffect(() => { 37 + useEffect(() => { 31 38 return persisted.onUpdate('imageCdnHost', nextImageCdnHost => { 32 39 setState(nextImageCdnHost) 33 40 }) ··· 43 50 } 44 51 45 52 export function useImageCdnHost() { 46 - return React.useContext(stateContext) ?? persisted.defaults.imageCdnHost! 53 + return useContext(stateContext) ?? persisted.defaults.imageCdnHost! 47 54 } 48 55 49 56 export function useSetImageCdnHost() { 50 - return React.useContext(setContext) 57 + return useContext(setContext) 51 58 } 52 59 53 60 function normalizeOrigin(input: string) {
+2 -1
src/state/preferences/in-app-browser.tsx
··· 5 5 useEffect, 6 6 useState, 7 7 } from 'react' 8 + import type {PropsWithChildren} from 'react' 8 9 9 10 import * as persisted from '#/state/persisted' 10 11 ··· 20 21 ) 21 22 setContext.displayName = 'InAppBrowserSetContext' 22 23 23 - export function Provider({children}: React.PropsWithChildren<{}>) { 24 + export function Provider({children}: PropsWithChildren<{}>) { 24 25 const [state, setState] = useState(persisted.get('useInAppBrowser')) 25 26 26 27 const setStateWrapped = useCallback(
+3 -1
src/state/preferences/index.tsx
··· 1 + import type {PropsWithChildren} from 'react' 2 + 1 3 import {Provider as AltTextRequiredProvider} from './alt-text-required' 2 4 import {Provider as AutoLikeOnRepostProvider} from './auto-like-on-repost' 3 5 import {Provider as AutoplayProvider} from './autoplay' ··· 97 99 useTranslationServicePreference, 98 100 } from './translation-service-preference' 99 101 100 - export function Provider({children}: React.PropsWithChildren<{}>) { 102 + export function Provider({children}: PropsWithChildren<{}>) { 101 103 return ( 102 104 <LanguagesProvider> 103 105 <AltTextRequiredProvider>
+2 -1
src/state/preferences/label-defs.tsx
··· 3 3 type AppBskyLabelerDefs, 4 4 type InterpretedLabelValueDefinition, 5 5 } from '@atproto/api' 6 + import type {PropsWithChildren} from 'react' 6 7 7 8 import {useLabelDefinitionsQuery} from '../queries/preferences' 8 9 ··· 17 18 }) 18 19 stateContext.displayName = 'LabelDefsStateContext' 19 20 20 - export function Provider({children}: React.PropsWithChildren<{}>) { 21 + export function Provider({children}: PropsWithChildren<{}>) { 21 22 const state = useLabelDefinitionsQuery() 22 23 return <stateContext.Provider value={state}>{children}</stateContext.Provider> 23 24 }
+2 -1
src/state/preferences/languages.tsx
··· 6 6 useMemo, 7 7 useState, 8 8 } from 'react' 9 + import type {PropsWithChildren} from 'react' 9 10 10 11 import {type AppLanguage} from '#/locale/languages' 11 12 import * as persisted from '#/state/persisted' ··· 36 37 }) 37 38 apiContext.displayName = 'LanguagePrefsApiContext' 38 39 39 - export function Provider({children}: React.PropsWithChildren<{}>) { 40 + export function Provider({children}: PropsWithChildren<{}>) { 40 41 const [state, setState] = useState(() => persisted.get('languagePrefs')) 41 42 42 43 const setStateWrapped = useCallback(
+2 -1
src/state/preferences/large-alt-badge.tsx
··· 5 5 useEffect, 6 6 useState, 7 7 } from 'react' 8 + import type {PropsWithChildren} from 'react' 8 9 9 10 import * as persisted from '#/state/persisted' 10 11 ··· 20 21 ) 21 22 setContext.displayName = 'LargeAltBadgeSetContext' 22 23 23 - export function Provider({children}: React.PropsWithChildren<{}>) { 24 + export function Provider({children}: PropsWithChildren<{}>) { 24 25 const [state, setState] = useState(persisted.get('largeAltBadgeEnabled')) 25 26 26 27 const setStateWrapped = useCallback(
+2 -1
src/state/preferences/moderation-opts.tsx
··· 1 1 import {createContext, useContext, useMemo} from 'react' 2 + import {type PropsWithChildren} from 'react' 2 3 import {BskyAgent, type ModerationOpts} from '@atproto/api' 3 4 4 5 import {useHiddenPosts, useLabelDefinitions} from '#/state/preferences' ··· 21 22 return useContext(moderationOptsContext) 22 23 } 23 24 24 - export function Provider({children}: React.PropsWithChildren<{}>) { 25 + export function Provider({children}: PropsWithChildren<{}>) { 25 26 const override = useContext(moderationOptsOverrideContext) 26 27 const {currentAccount} = useSession() 27 28 const prefs = usePreferencesQuery()
+16 -9
src/state/preferences/no-app-labelers.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['noAppLabelers'] 6 13 type SetContext = (v: persisted.Schema['noAppLabelers']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 15 + const stateContext = createContext<StateContext>( 9 16 persisted.defaults.noAppLabelers, 10 17 ) 11 - const setContext = React.createContext<SetContext>( 18 + const setContext = createContext<SetContext>( 12 19 (_: persisted.Schema['noAppLabelers']) => {}, 13 20 ) 14 21 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState(persisted.get('noAppLabelers')) 22 + export function Provider({children}: PropsWithChildren<{}>) { 23 + const [state, setState] = useState(persisted.get('noAppLabelers')) 17 24 18 - const setStateWrapped = React.useCallback( 25 + const setStateWrapped = useCallback( 19 26 (noAppLabelers: persisted.Schema['noAppLabelers']) => { 20 27 setState(noAppLabelers) 21 28 persisted.write('noAppLabelers', noAppLabelers) ··· 23 30 [setState], 24 31 ) 25 32 26 - React.useEffect(() => { 33 + useEffect(() => { 27 34 return persisted.onUpdate('noAppLabelers', nextNoAppLabelers => { 28 35 setState(nextNoAppLabelers) 29 36 }) ··· 39 46 } 40 47 41 48 export function useNoAppLabelers() { 42 - return React.useContext(stateContext) 49 + return useContext(stateContext) 43 50 } 44 51 45 52 export function useSetNoAppLabelers() { 46 - return React.useContext(setContext) 53 + return useContext(setContext) 47 54 } 48 55 49 56 export function getNoAppLabelers() {
+16 -9
src/state/preferences/no-discover-fallback.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['noDiscoverFallback'] 6 13 type SetContext = (v: persisted.Schema['noDiscoverFallback']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 15 + const stateContext = createContext<StateContext>( 9 16 persisted.defaults.noDiscoverFallback, 10 17 ) 11 - const setContext = React.createContext<SetContext>( 18 + const setContext = createContext<SetContext>( 12 19 (_: persisted.Schema['noDiscoverFallback']) => {}, 13 20 ) 14 21 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState(persisted.get('noDiscoverFallback')) 22 + export function Provider({children}: PropsWithChildren<{}>) { 23 + const [state, setState] = useState(persisted.get('noDiscoverFallback')) 17 24 18 - const setStateWrapped = React.useCallback( 25 + const setStateWrapped = useCallback( 19 26 (noDiscoverFallback: persisted.Schema['noDiscoverFallback']) => { 20 27 setState(noDiscoverFallback) 21 28 persisted.write('noDiscoverFallback', noDiscoverFallback) ··· 23 30 [setState], 24 31 ) 25 32 26 - React.useEffect(() => { 33 + useEffect(() => { 27 34 return persisted.onUpdate('noDiscoverFallback', nextNoDiscoverFallback => { 28 35 setState(nextNoDiscoverFallback) 29 36 }) ··· 39 46 } 40 47 41 48 export function useNoDiscoverFallback() { 42 - return React.useContext(stateContext) 49 + return useContext(stateContext) 43 50 } 44 51 45 52 export function useSetNoDiscoverFallback() { 46 - return React.useContext(setContext) 53 + return useContext(setContext) 47 54 }
+30 -25
src/state/preferences/openrouter.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 9 16 type PromptStateContext = persisted.Schema['openRouterPrompt'] 10 17 type SetPromptContext = (v: persisted.Schema['openRouterPrompt']) => void 11 18 12 - const apiKeyStateContext = React.createContext<ApiKeyStateContext>( 19 + const apiKeyStateContext = createContext<ApiKeyStateContext>( 13 20 persisted.defaults.openRouterApiKey, 14 21 ) 15 - const setApiKeyContext = React.createContext<SetApiKeyContext>( 22 + const setApiKeyContext = createContext<SetApiKeyContext>( 16 23 (_: persisted.Schema['openRouterApiKey']) => {}, 17 24 ) 18 - const modelStateContext = React.createContext<ModelStateContext>( 25 + const modelStateContext = createContext<ModelStateContext>( 19 26 persisted.defaults.openRouterModel, 20 27 ) 21 - const setModelContext = React.createContext<SetModelContext>( 28 + const setModelContext = createContext<SetModelContext>( 22 29 (_: persisted.Schema['openRouterModel']) => {}, 23 30 ) 24 - const promptStateContext = React.createContext<PromptStateContext>( 31 + const promptStateContext = createContext<PromptStateContext>( 25 32 persisted.defaults.openRouterPrompt, 26 33 ) 27 - const setPromptContext = React.createContext<SetPromptContext>( 34 + const setPromptContext = createContext<SetPromptContext>( 28 35 (_: persisted.Schema['openRouterPrompt']) => {}, 29 36 ) 30 37 31 - export function Provider({children}: React.PropsWithChildren<{}>) { 32 - const [apiKeyState, setApiKeyState] = React.useState( 38 + export function Provider({children}: PropsWithChildren<{}>) { 39 + const [apiKeyState, setApiKeyState] = useState( 33 40 persisted.get('openRouterApiKey'), 34 41 ) 35 - const [modelState, setModelState] = React.useState( 36 - persisted.get('openRouterModel'), 37 - ) 38 - const [promptState, setPromptState] = React.useState( 42 + const [modelState, setModelState] = useState(persisted.get('openRouterModel')) 43 + const [promptState, setPromptState] = useState( 39 44 persisted.get('openRouterPrompt'), 40 45 ) 41 46 42 - const setApiKeyWrapped = React.useCallback( 47 + const setApiKeyWrapped = useCallback( 43 48 (openRouterApiKey: persisted.Schema['openRouterApiKey']) => { 44 49 setApiKeyState(openRouterApiKey) 45 50 persisted.write('openRouterApiKey', openRouterApiKey) ··· 47 52 [setApiKeyState], 48 53 ) 49 54 50 - const setModelWrapped = React.useCallback( 55 + const setModelWrapped = useCallback( 51 56 (openRouterModel: persisted.Schema['openRouterModel']) => { 52 57 setModelState(openRouterModel) 53 58 persisted.write('openRouterModel', openRouterModel) ··· 55 60 [setModelState], 56 61 ) 57 62 58 - const setPromptWrapped = React.useCallback( 63 + const setPromptWrapped = useCallback( 59 64 (openRouterPrompt: persisted.Schema['openRouterPrompt']) => { 60 65 setPromptState(openRouterPrompt) 61 66 persisted.write('openRouterPrompt', openRouterPrompt) ··· 63 68 [setPromptState], 64 69 ) 65 70 66 - React.useEffect(() => { 71 + useEffect(() => { 67 72 return persisted.onUpdate('openRouterApiKey', nextApiKey => { 68 73 setApiKeyState(nextApiKey) 69 74 }) 70 75 }, [setApiKeyWrapped]) 71 76 72 - React.useEffect(() => { 77 + useEffect(() => { 73 78 return persisted.onUpdate('openRouterModel', nextModel => { 74 79 setModelState(nextModel) 75 80 }) 76 81 }, [setModelWrapped]) 77 82 78 - React.useEffect(() => { 83 + useEffect(() => { 79 84 return persisted.onUpdate('openRouterPrompt', nextPrompt => { 80 85 setPromptState(nextPrompt) 81 86 }) ··· 99 104 } 100 105 101 106 export function useOpenRouterApiKey() { 102 - return React.useContext(apiKeyStateContext) 107 + return useContext(apiKeyStateContext) 103 108 } 104 109 105 110 export function useSetOpenRouterApiKey() { 106 - return React.useContext(setApiKeyContext) 111 + return useContext(setApiKeyContext) 107 112 } 108 113 109 114 export function useOpenRouterModel() { 110 - return React.useContext(modelStateContext) 115 + return useContext(modelStateContext) 111 116 } 112 117 113 118 export function useSetOpenRouterModel() { 114 - return React.useContext(setModelContext) 119 + return useContext(setModelContext) 115 120 } 116 121 117 122 export function useOpenRouterPrompt() { 118 - return React.useContext(promptStateContext) 123 + return useContext(promptStateContext) 119 124 } 120 125 121 126 export function useSetOpenRouterPrompt() { 122 - return React.useContext(setPromptContext) 127 + return useContext(setPromptContext) 123 128 } 124 129 125 130 export function useOpenRouterConfigured() {
+19 -14
src/state/preferences/pds-label.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useContext, 5 + useEffect, 6 + useMemo, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['pdsLabel'] 6 13 type SetContext = (v: persisted.Schema['pdsLabel']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 9 - persisted.defaults.pdsLabel, 10 - ) 11 - const setContext = React.createContext<SetContext>( 15 + const stateContext = createContext<StateContext>(persisted.defaults.pdsLabel) 16 + const setContext = createContext<SetContext>( 12 17 (_: persisted.Schema['pdsLabel']) => {}, 13 18 ) 14 19 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState(persisted.get('pdsLabel')) 20 + export function Provider({children}: PropsWithChildren<{}>) { 21 + const [state, setState] = useState(persisted.get('pdsLabel')) 17 22 18 - const setStateWrapped = React.useCallback( 19 - (pdsLabel: persisted.Schema['pdsLabel']) => { 23 + const setStateWrapped = useMemo( 24 + () => (pdsLabel: persisted.Schema['pdsLabel']) => { 20 25 setState(pdsLabel) 21 26 persisted.write('pdsLabel', pdsLabel) 22 27 }, 23 28 [setState], 24 29 ) 25 30 26 - React.useEffect(() => { 31 + useEffect(() => { 27 32 return persisted.onUpdate('pdsLabel', next => { 28 33 setState(next) 29 34 }) ··· 39 44 } 40 45 41 46 export function usePdsLabel() { 42 - return React.useContext(stateContext) ?? persisted.defaults.pdsLabel! 47 + return useContext(stateContext) ?? persisted.defaults.pdsLabel! 43 48 } 44 49 45 50 export function usePdsLabelEnabled() { ··· 51 56 } 52 57 53 58 export function useSetPdsLabel() { 54 - return React.useContext(setContext) 59 + return useContext(setContext) 55 60 } 56 61 57 62 export function useSetPdsLabelEnabled() { 58 63 const pdsLabel = usePdsLabel() 59 64 const setPdsLabel = useSetPdsLabel() 60 65 61 - return React.useMemo( 66 + return useMemo( 62 67 () => (enabled: boolean) => setPdsLabel({...pdsLabel, enabled}), 63 68 [pdsLabel, setPdsLabel], 64 69 ) ··· 68 73 const pdsLabel = usePdsLabel() 69 74 const setPdsLabel = useSetPdsLabel() 70 75 71 - return React.useMemo( 76 + return useMemo( 72 77 () => (hideBskyPds: boolean) => setPdsLabel({...pdsLabel, hideBskyPds}), 73 78 [pdsLabel, setPdsLabel], 74 79 )
+16 -9
src/state/preferences/plc-directory.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['plcDirectory'] 6 13 type SetContext = (v: persisted.Schema['plcDirectory']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 15 + const stateContext = createContext<StateContext>( 9 16 persisted.defaults.plcDirectory, 10 17 ) 11 - const setContext = React.createContext<SetContext>( 18 + const setContext = createContext<SetContext>( 12 19 (_: persisted.Schema['plcDirectory']) => {}, 13 20 ) 14 21 ··· 20 27 } 21 28 } 22 29 23 - export function Provider({children}: React.PropsWithChildren<{}>) { 24 - const [state, setState] = React.useState(persisted.get('plcDirectory')) 30 + export function Provider({children}: PropsWithChildren<{}>) { 31 + const [state, setState] = useState(persisted.get('plcDirectory')) 25 32 26 - const setStateWrapped = React.useCallback( 33 + const setStateWrapped = useCallback( 27 34 (plcDirectory: persisted.Schema['plcDirectory']) => { 28 35 setState(plcDirectory) 29 36 persisted.write('plcDirectory', plcDirectory) ··· 31 38 [setState], 32 39 ) 33 40 34 - React.useEffect(() => { 41 + useEffect(() => { 35 42 return persisted.onUpdate('plcDirectory', nextPlcDirectory => { 36 43 setState(nextPlcDirectory) 37 44 }) ··· 49 56 export function usePlcDirectory() { 50 57 return ( 51 58 normalizeOrigin( 52 - React.useContext(stateContext) ?? persisted.defaults.plcDirectory!, 59 + useContext(stateContext) ?? persisted.defaults.plcDirectory!, 53 60 ) ?? persisted.defaults.plcDirectory! 54 61 ) 55 62 } 56 63 57 64 export function useSetPlcDirectory() { 58 - return React.useContext(setContext) 65 + return useContext(setContext) 59 66 } 60 67 61 68 export function readPlcDirectory() {
+16 -9
src/state/preferences/post-name-replacement.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 15 22 | ((curr: PostReplacementState) => PostReplacementState), 16 23 ) => void 17 24 18 - const stateContext = React.createContext<StateContext>( 25 + const stateContext = createContext<StateContext>( 19 26 persisted.defaults.postReplacement as PostReplacementState, 20 27 ) 21 - const setContext = React.createContext<SetContext>( 28 + const setContext = createContext<SetContext>( 22 29 ( 23 30 _: 24 31 | PostReplacementState ··· 26 33 ) => {}, 27 34 ) 28 35 29 - export function Provider({children}: React.PropsWithChildren<{}>) { 30 - const [state, _setState] = React.useState<PostReplacementState>(() => { 36 + export function Provider({children}: PropsWithChildren<{}>) { 37 + const [state, _setState] = useState<PostReplacementState>(() => { 31 38 const persistedState = persisted.get('postReplacement') 32 39 return { 33 40 enabled: ··· 41 48 } 42 49 }) 43 50 44 - const setState = React.useCallback( 51 + const setState = useCallback( 45 52 ( 46 53 val: 47 54 | PostReplacementState ··· 56 63 [], 57 64 ) 58 65 59 - React.useEffect(() => { 66 + useEffect(() => { 60 67 return persisted.onUpdate('postReplacement', next => { 61 68 setState({ 62 69 postName: next.postName ?? 'skeet', ··· 74 81 } 75 82 76 83 export function usePostReplacement() { 77 - return React.useContext(stateContext) 84 + return useContext(stateContext) 78 85 } 79 86 80 87 export function useSetPostReplacement() { 81 - return React.useContext(setContext) 88 + return useContext(setContext) 82 89 }
+16 -9
src/state/preferences/show-follows-you-badge.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 5 12 type StateContext = persisted.Schema['showFollowsYouBadge'] 6 13 type SetContext = (v: persisted.Schema['showFollowsYouBadge']) => void 7 14 8 - const stateContext = React.createContext<StateContext>( 15 + const stateContext = createContext<StateContext>( 9 16 persisted.defaults.showFollowsYouBadge, 10 17 ) 11 - const setContext = React.createContext<SetContext>( 18 + const setContext = createContext<SetContext>( 12 19 (_: persisted.Schema['showFollowsYouBadge']) => {}, 13 20 ) 14 21 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState(persisted.get('showFollowsYouBadge')) 22 + export function Provider({children}: PropsWithChildren<{}>) { 23 + const [state, setState] = useState(persisted.get('showFollowsYouBadge')) 17 24 18 - const setStateWrapped = React.useCallback( 25 + const setStateWrapped = useCallback( 19 26 (showFollowsYouBadge: persisted.Schema['showFollowsYouBadge']) => { 20 27 setState(showFollowsYouBadge) 21 28 persisted.write('showFollowsYouBadge', showFollowsYouBadge) ··· 23 30 [setState], 24 31 ) 25 32 26 - React.useEffect(() => { 33 + useEffect(() => { 27 34 return persisted.onUpdate( 28 35 'showFollowsYouBadge', 29 36 nextShowFollowsYouBadge => { ··· 42 49 } 43 50 44 51 export function useShowFollowsYouBadge() { 45 - return React.useContext(stateContext) 52 + return useContext(stateContext) 46 53 } 47 54 48 55 export function useSetShowFollowsYouBadge() { 49 - return React.useContext(setContext) 56 + return useContext(setContext) 50 57 }
+2 -1
src/state/preferences/subtitles.tsx
··· 5 5 useEffect, 6 6 useState, 7 7 } from 'react' 8 + import type {PropsWithChildren} from 'react' 8 9 9 10 import * as persisted from '#/state/persisted' 10 11 ··· 18 19 const setContext = createContext<SetContext>((_: boolean) => {}) 19 20 setContext.displayName = 'SubtitlesSetContext' 20 21 21 - export function Provider({children}: {children: React.ReactNode}) { 22 + export function Provider({children}: PropsWithChildren<{}>) { 22 23 const [state, setState] = useState(Boolean(persisted.get('subtitlesEnabled'))) 23 24 24 25 const setStateWrapped = useCallback(
+23 -16
src/state/preferences/translation-service-preference.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 3 10 import * as persisted from '#/state/persisted' 4 11 ··· 9 16 v: persisted.Schema['libreTranslateInstance'], 10 17 ) => void 11 18 12 - const stateContext = React.createContext<StateContext>( 19 + const stateContext = createContext<StateContext>( 13 20 persisted.defaults.translationServicePreference, 14 21 ) 15 - const setContext = React.createContext<SetContext>( 22 + const setContext = createContext<SetContext>( 16 23 (_: persisted.Schema['translationServicePreference']) => {}, 17 24 ) 18 - const instanceStateContext = React.createContext<InstanceStateContext>( 25 + const instanceStateContext = createContext<InstanceStateContext>( 19 26 persisted.defaults.libreTranslateInstance, 20 27 ) 21 - const setInstanceContext = React.createContext<SetInstanceContext>( 28 + const setInstanceContext = createContext<SetInstanceContext>( 22 29 (_: persisted.Schema['libreTranslateInstance']) => {}, 23 30 ) 24 31 25 - export function Provider({children}: React.PropsWithChildren<{}>) { 26 - const [state, setState] = React.useState( 32 + export function Provider({children}: PropsWithChildren<{}>) { 33 + const [state, setState] = useState( 27 34 persisted.get('translationServicePreference'), 28 35 ) 29 - const [instanceState, setInstanceState] = React.useState( 36 + const [instanceState, setInstanceState] = useState( 30 37 persisted.get('libreTranslateInstance'), 31 38 ) 32 39 33 - const setStateWrapped = React.useCallback( 40 + const setStateWrapped = useCallback( 34 41 ( 35 42 translationServicePreference: persisted.Schema['translationServicePreference'], 36 43 ) => { ··· 43 50 [setState], 44 51 ) 45 52 46 - const setInstanceStateWrapped = React.useCallback( 53 + const setInstanceStateWrapped = useCallback( 47 54 (libreTranslateInstance: persisted.Schema['libreTranslateInstance']) => { 48 55 setInstanceState(libreTranslateInstance) 49 56 persisted.write('libreTranslateInstance', libreTranslateInstance) ··· 51 58 [setInstanceState], 52 59 ) 53 60 54 - React.useEffect(() => { 61 + useEffect(() => { 55 62 return persisted.onUpdate( 56 63 'translationServicePreference', 57 64 nextTranslationServicePreference => { ··· 60 67 ) 61 68 }, [setStateWrapped]) 62 69 63 - React.useEffect(() => { 70 + useEffect(() => { 64 71 return persisted.onUpdate('libreTranslateInstance', nextInstance => { 65 72 setInstanceState(nextInstance) 66 73 }) ··· 80 87 } 81 88 82 89 export function useTranslationServicePreference() { 83 - return React.useContext(stateContext) 90 + return useContext(stateContext) 84 91 } 85 92 86 93 export function useSetTranslationServicePreference() { 87 - return React.useContext(setContext) 94 + return useContext(setContext) 88 95 } 89 96 90 97 export function useLibreTranslateInstance() { 91 98 return ( 92 - React.useContext(instanceStateContext) ?? 99 + useContext(instanceStateContext) ?? 93 100 persisted.defaults.libreTranslateInstance! 94 101 ) 95 102 } 96 103 97 104 export function useSetLibreTranslateInstance() { 98 - return React.useContext(setInstanceContext) 105 + return useContext(setInstanceContext) 99 106 }
+2 -1
src/state/preferences/trending.tsx
··· 6 6 useMemo, 7 7 useState, 8 8 } from 'react' 9 + import type {PropsWithChildren} from 'react' 9 10 10 11 import * as persisted from '#/state/persisted' 11 12 ··· 58 59 return [value, set] as const 59 60 } 60 61 61 - export function Provider({children}: React.PropsWithChildren<{}>) { 62 + export function Provider({children}: PropsWithChildren<{}>) { 62 63 const [trendingDisabled, setTrendingDisabled] = 63 64 usePersistedBooleanValue('trendingDisabled') 64 65 const [trendingVideoDisabled, setTrendingVideoDisabled] =
+17 -10
src/state/preferences/use-handle-in-links.tsx
··· 1 - import React from 'react' 1 + import { 2 + createContext, 3 + type PropsWithChildren, 4 + useCallback, 5 + useContext, 6 + useEffect, 7 + useState, 8 + } from 'react' 2 9 import {reloadAppAsync} from 'expo' 3 10 4 11 import * as persisted from '#/state/persisted' ··· 7 14 type StateContext = persisted.Schema['useHandleInLinks'] 8 15 type SetContext = (v: persisted.Schema['useHandleInLinks']) => void 9 16 10 - const stateContext = React.createContext<StateContext>( 17 + const stateContext = createContext<StateContext>( 11 18 persisted.defaults.useHandleInLinks, 12 19 ) 13 - const setContext = React.createContext<SetContext>( 20 + const setContext = createContext<SetContext>( 14 21 (_: persisted.Schema['useHandleInLinks']) => {}, 15 22 ) 16 23 17 - export function Provider({children}: React.PropsWithChildren<{}>) { 18 - const [state, setState] = React.useState(persisted.get('useHandleInLinks')) 24 + export function Provider({children}: PropsWithChildren<{}>) { 25 + const [state, setState] = useState(persisted.get('useHandleInLinks')) 19 26 20 - const setStateWrapped = React.useCallback( 27 + const setStateWrapped = useCallback( 21 28 (useHandleInLinks: persisted.Schema['useHandleInLinks']) => { 22 29 setState(useHandleInLinks) 23 30 persisted.write('useHandleInLinks', useHandleInLinks) ··· 25 32 [setState], 26 33 ) 27 34 28 - React.useEffect(() => { 35 + useEffect(() => { 29 36 return persisted.onUpdate('useHandleInLinks', nextUseHandleInLinks => { 30 37 setState(nextUseHandleInLinks) 31 38 }) ··· 41 48 } 42 49 43 50 export function useHandleInLinks() { 44 - return React.useContext(stateContext) 51 + return useContext(stateContext) 45 52 } 46 53 47 54 export function useSetHandleInLinks() { 48 - const set = React.useContext(setContext) 55 + const set = useContext(setContext) 49 56 50 - return React.useCallback( 57 + return useCallback( 51 58 (useHandleInLinks: persisted.Schema['useHandleInLinks']) => { 52 59 set(useHandleInLinks) 53 60
+2 -1
src/state/preferences/used-starter-packs.tsx
··· 1 1 import {createContext, useContext, useEffect, useState} from 'react' 2 + import type {ReactNode} from 'react' 2 3 3 4 import * as persisted from '#/state/persisted' 4 5 ··· 10 11 const setContext = createContext<SetContext>((_: boolean) => {}) 11 12 setContext.displayName = 'UsedStarterPacksSetContext' 12 13 13 - export function Provider({children}: {children: React.ReactNode}) { 14 + export function Provider({children}: {children: ReactNode}) { 14 15 const [state, setState] = useState<StateContext>(() => 15 16 persisted.get('hasCheckedForStarterPack'), 16 17 )
+1 -1
src/state/session/index.tsx
··· 8 8 useState, 9 9 useSyncExternalStore, 10 10 } from 'react' 11 - import {type Agent, type AtpAgent, type AtpSessionEvent} from '@atproto/api' 11 + import {type AtpAgent, type AtpSessionEvent} from '@atproto/api' 12 12 13 13 import * as persisted from '#/state/persisted' 14 14 import {useCloseAllActiveElements} from '#/state/util'
+1
src/state/session/oauth-native-client.ts
··· 1 1 import {ExpoOAuthClient} from '@atproto/oauth-client-expo' 2 + 2 3 import {createIdentityResolver} from './identity-resolver' 3 4 4 5 const OAUTH_BASE_URL: string =
+2 -2
src/view/com/composer/Composer.tsx
··· 785 785 } 786 786 }, [onPressCancel, closeAllDialogs, closeAllModals]) 787 787 788 - const missingAltError = useMemo(() => { 788 + const missingAltError = (() => { 789 789 if (!requireAltTextEnabled) { 790 790 return 791 791 } ··· 807 807 } 808 808 } 809 809 } 810 - }, [thread, requireAltTextEnabled, l]) 810 + })() 811 811 812 812 const canPost = 813 813 !missingAltError &&
+27 -37
src/view/com/pager/Pager.web.tsx
··· 1 - import { 2 - Children, 3 - type JSX, 4 - useCallback, 5 - useImperativeHandle, 6 - useRef, 7 - useState, 8 - } from 'react' 1 + import {Children, type JSX, useImperativeHandle, useRef, useState} from 'react' 9 2 import {View} from 'react-native' 10 3 import {flushSync} from 'react-dom' 11 4 ··· 47 40 }, 48 41 })) 49 42 50 - const onTabBarSelect = useCallback( 51 - (index: number) => { 52 - const scrollY = window.scrollY 53 - // We want to determine if the tabbar is already "sticking" at the top (in which 54 - // case we should preserve and restore scroll), or if it is somewhere below in the 55 - // viewport (in which case a scroll jump would be jarring). We determine this by 56 - // measuring where the "anchor" element is (which we place just above the tabbar). 57 - let anchorTop = anchorRef.current 58 - ? (anchorRef.current as Element).getBoundingClientRect().top 59 - : -scrollY // If there's no anchor, treat the top of the page as one. 60 - const isSticking = anchorTop <= 5 // This would be 0 if browser scrollTo() was reliable. 43 + const onTabBarSelect = (index: number) => { 44 + const scrollY = window.scrollY 45 + // We want to determine if the tabbar is already "sticking" at the top (in which 46 + // case we should preserve and restore scroll), or if it is somewhere below in the 47 + // viewport (in which case a scroll jump would be jarring). We determine this by 48 + // measuring where the "anchor" element is (which we place just above the tabbar). 49 + let anchorTop = anchorRef.current 50 + ? (anchorRef.current as Element).getBoundingClientRect().top 51 + : -scrollY // If there's no anchor, treat the top of the page as one. 52 + const isSticking = anchorTop <= 5 // This would be 0 if browser scrollTo() was reliable. 61 53 62 - if (isSticking) { 63 - scrollYs.current[selectedPage] = window.scrollY 54 + if (isSticking) { 55 + scrollYs.current[selectedPage] = window.scrollY 56 + } else { 57 + scrollYs.current[selectedPage] = null 58 + } 59 + flushSync(() => { 60 + setSelectedPage(index) 61 + onPageSelected?.(index) 62 + }) 63 + if (isSticking) { 64 + const restoredScrollY = scrollYs.current[index] 65 + if (restoredScrollY != null) { 66 + window.scrollTo(0, restoredScrollY) 64 67 } else { 65 - scrollYs.current[selectedPage] = null 68 + window.scrollTo(0, scrollY + anchorTop) 66 69 } 67 - flushSync(() => { 68 - setSelectedPage(index) 69 - onPageSelected?.(index) 70 - }) 71 - if (isSticking) { 72 - const restoredScrollY = scrollYs.current[index] 73 - if (restoredScrollY != null) { 74 - window.scrollTo(0, restoredScrollY) 75 - } else { 76 - window.scrollTo(0, scrollY + anchorTop) 77 - } 78 - } 79 - }, 80 - [selectedPage, setSelectedPage, onPageSelected], 81 - ) 70 + } 71 + } 82 72 83 73 return ( 84 74 <View style={s.hContentRegion}>
+6 -6
src/view/com/posts/PostFeedItemCarousel.tsx
··· 1 - import React from 'react' 1 + import {useCallback, useRef, useState} from 'react' 2 2 import {Dimensions, ScrollView, View} from 'react-native' 3 3 import {msg} from '@lingui/core/macro' 4 4 import {useLingui} from '@lingui/react' ··· 22 22 export function PostFeedItemCarousel({items}: {items: FeedPostSlice[]}) { 23 23 const t = useTheme() 24 24 const {_} = useLingui() 25 - const ref = React.useRef<ScrollView>(null) 26 - const [scrollX, setScrollX] = React.useState(0) 25 + const ref = useRef<ScrollView>(null) 26 + const [scrollX, setScrollX] = useState(0) 27 27 28 28 const enableSquareButtons = useEnableSquareButtons() 29 29 30 - const scrollTo = React.useCallback( 30 + const scrollTo = useCallback( 31 31 (item: number) => { 32 32 setScrollX(item) 33 33 ··· 40 40 [ref], 41 41 ) 42 42 43 - const scrollLeft = React.useCallback(() => { 43 + const scrollLeft = useCallback(() => { 44 44 const newPos = scrollX > 0 ? scrollX - 1 : items.length - 1 45 45 scrollTo(newPos) 46 46 }, [scrollTo, scrollX, items.length]) 47 47 48 - const scrollRight = React.useCallback(() => { 48 + const scrollRight = useCallback(() => { 49 49 const newPos = scrollX < items.length - 1 ? scrollX + 1 : 0 50 50 scrollTo(newPos) 51 51 }, [scrollTo, scrollX, items.length])