deer social fork for personal usage. but you might see a use idk. github mirror

remove some unused stuff

aylac.top ceab9daf 9109bb8b

verified
-47
assets/app-icons/icon_default_next.png

This is a binary file and will not be displayed.

-47
src/state/preferences/country-code.tsx
··· 1 - import React from 'react' 2 - 3 - import * as persisted from '#/state/persisted' 4 - 5 - type StateContext = persisted.Schema['countryCode'] 6 - type SetContext = (v: persisted.Schema['countryCode']) => void 7 - 8 - const stateContext = React.createContext<StateContext>( 9 - persisted.defaults.countryCode, 10 - ) 11 - const setContext = React.createContext<SetContext>( 12 - (_: persisted.Schema['countryCode']) => {}, 13 - ) 14 - 15 - export function Provider({children}: React.PropsWithChildren<{}>) { 16 - const [state, setState] = React.useState(persisted.get('countryCode')) 17 - 18 - const setStateWrapped = React.useCallback( 19 - (countryCode: persisted.Schema['countryCode']) => { 20 - setState(countryCode) 21 - persisted.write('countryCode', countryCode) 22 - }, 23 - [setState], 24 - ) 25 - 26 - React.useEffect(() => { 27 - return persisted.onUpdate('countryCode', nextCountryCode => { 28 - setState(nextCountryCode) 29 - }) 30 - }, [setStateWrapped]) 31 - 32 - return ( 33 - <stateContext.Provider value={state}> 34 - <setContext.Provider value={setStateWrapped}> 35 - {children} 36 - </setContext.Provider> 37 - </stateContext.Provider> 38 - ) 39 - } 40 - 41 - export function useCountryCode() { 42 - return React.useContext(stateContext) 43 - } 44 - 45 - export function useSetCountryCode() { 46 - return React.useContext(setContext) 47 - }