diff options
author | dan <dan.abramov@gmail.com> | 2024-11-25 20:30:33 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-25 20:30:33 +0000 |
commit | c6c6c91d7b0b549af28aa14dedf194e65770eb90 (patch) | |
tree | 6bbf6f6271784dde9322c6d61a09faba06653948 /src/state/preferences/opt-out-of-utm.tsx | |
parent | b0c36383a9a7304f94c2bb19f7cc4b37e0b4f637 (diff) | |
download | voidsky-c6c6c91d7b0b549af28aa14dedf194e65770eb90.tar.zst |
This reverts commit ac5b2cf31f2bb45f1bf8a180705249d3cce8017d.
Diffstat (limited to 'src/state/preferences/opt-out-of-utm.tsx')
-rw-r--r-- | src/state/preferences/opt-out-of-utm.tsx | 42 |
1 files changed, 0 insertions, 42 deletions
diff --git a/src/state/preferences/opt-out-of-utm.tsx b/src/state/preferences/opt-out-of-utm.tsx deleted file mode 100644 index 40144c8db..000000000 --- a/src/state/preferences/opt-out-of-utm.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import React from 'react' - -import * as persisted from '#/state/persisted' - -type StateContext = boolean -type SetContext = (v: boolean) => void - -const stateContext = React.createContext<StateContext>( - Boolean(persisted.defaults.optOutOfUtm), -) -const setContext = React.createContext<SetContext>((_: boolean) => {}) - -export function Provider({children}: {children: React.ReactNode}) { - const [state, setState] = React.useState( - Boolean(persisted.get('optOutOfUtm')), - ) - - const setStateWrapped = React.useCallback( - (optOutOfUtm: persisted.Schema['optOutOfUtm']) => { - setState(Boolean(optOutOfUtm)) - persisted.write('optOutOfUtm', optOutOfUtm) - }, - [setState], - ) - - React.useEffect(() => { - return persisted.onUpdate('optOutOfUtm', nextOptOutOfUtm => { - setState(Boolean(nextOptOutOfUtm)) - }) - }, [setStateWrapped]) - - return ( - <stateContext.Provider value={state}> - <setContext.Provider value={setStateWrapped}> - {children} - </setContext.Provider> - </stateContext.Provider> - ) -} - -export const useOptOutOfUtm = () => React.useContext(stateContext) -export const useSetOptOutOfUtm = () => React.useContext(setContext) |