Bluesky app fork with some witchin' additions 馃挮
0
fork

Configure Feed

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

at main 41 lines 1.1 kB view raw
1import {createContext, useContext, useState} from 'react' 2 3import {useHotkeysContext} from '#/lib/hotkeys' 4 5type StateContext = boolean 6type SetContext = (v: boolean) => void 7 8const stateContext = createContext<StateContext>(false) 9stateContext.displayName = 'DrawerOpenStateContext' 10const setContext = createContext<SetContext>((_: boolean) => {}) 11setContext.displayName = 'DrawerOpenSetContext' 12 13export function Provider({children}: React.PropsWithChildren<{}>) { 14 const [state, setState] = useState(false) 15 const {disableScope, enableScope} = useHotkeysContext() 16 17 const setDrawerOpen = (open: boolean) => { 18 if (open) { 19 disableScope('global') 20 } else { 21 enableScope('global') 22 } 23 setState(open) 24 } 25 26 return ( 27 <stateContext.Provider value={state}> 28 <setContext.Provider value={setDrawerOpen}> 29 {children} 30 </setContext.Provider> 31 </stateContext.Provider> 32 ) 33} 34 35export function useIsDrawerOpen() { 36 return useContext(stateContext) 37} 38 39export function useSetDrawerOpen() { 40 return useContext(setContext) 41}