···11+import React from 'react'
22+33+import * as persisted from '#/state/persisted'
44+55+// Preference: disableViaRepostNotification – when true, disables notifications sent when liking/reposting a post someone else reposted
66+77+type StateContext = persisted.Schema['disableViaRepostNotification']
88+// Same setter signature used across other preference modules
99+type SetContext = (v: persisted.Schema['disableViaRepostNotification']) => void
1010+1111+const stateContext = React.createContext<StateContext>(
1212+ persisted.defaults.disableViaRepostNotification,
1313+)
1414+const setContext = React.createContext<SetContext>(
1515+ (_: persisted.Schema['disableViaRepostNotification']) => {},
1616+)
1717+1818+export function Provider({children}: React.PropsWithChildren<{}>) {
1919+ const [state, setState] = React.useState(
2020+ persisted.get('disableViaRepostNotification'),
2121+ )
2222+2323+ const setStateWrapped = React.useCallback(
2424+ (value: persisted.Schema['disableViaRepostNotification']) => {
2525+ setState(value)
2626+ persisted.write('disableViaRepostNotification', value)
2727+ },
2828+ [setState],
2929+ )
3030+3131+ React.useEffect(() => {
3232+ return persisted.onUpdate('disableViaRepostNotification', next => {
3333+ setState(next)
3434+ })
3535+ }, [setStateWrapped])
3636+3737+ return (
3838+ <stateContext.Provider value={state}>
3939+ <setContext.Provider value={setStateWrapped}>
4040+ {children}
4141+ </setContext.Provider>
4242+ </stateContext.Provider>
4343+ )
4444+}
4545+4646+export function useDisableViaRepostNotification() {
4747+ return React.useContext(stateContext)
4848+}
4949+5050+export function useSetDisableViaRepostNotification() {
5151+ return React.useContext(setContext)
5252+}
+4-1
src/state/preferences/index.tsx
···77import {Provider as DeerVerificationProvider} from './deer-verification'
88import {Provider as DirectFetchRecordsProvider} from './direct-fetch-records'
99import {Provider as DisableHapticsProvider} from './disable-haptics'
1010+import {Provider as DisableViaRepostNotificationProvider} from './disable-via-repost-notification'
1011import {Provider as ExternalEmbedsProvider} from './external-embeds-prefs'
1112import {Provider as GoLinksProvider} from './go-links-enabled'
1213import {Provider as HiddenPostsProvider} from './hidden-posts'
···6970 <RepostCarouselProvider>
7071 <KawaiiProvider>
7172 <HideFeedsPromoTabProvider>
7272- {children}
7373+ <DisableViaRepostNotificationProvider>
7474+ {children}
7575+ </DisableViaRepostNotificationProvider>
7376 </HideFeedsPromoTabProvider>
7477 </KawaiiProvider>
7578 </RepostCarouselProvider>