diff options
author | dan <dan.abramov@gmail.com> | 2024-12-15 20:30:17 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-15 20:30:17 +0000 |
commit | 1ac307bc42bdf370c2011e7e7f2c76baea3441d2 (patch) | |
tree | 5e5b1513c1c35115d3eed73ae9a11178cd48a525 /src/state/home-badge.tsx | |
parent | 80c0125d6bfbafe463c526f37dab62f5f6604883 (diff) | |
download | voidsky-1ac307bc42bdf370c2011e7e7f2c76baea3441d2.tar.zst |
[Experiment] Remove "Load Latest" button (#7120)
* Remove "show latest" behind the gate * Add HomeBadgeProvider * Update provider state from home feed tabs * Add Home badge to native * Add Home badge to mobile web * Add Home badge to desktop web
Diffstat (limited to 'src/state/home-badge.tsx')
-rw-r--r-- | src/state/home-badge.tsx | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/state/home-badge.tsx b/src/state/home-badge.tsx new file mode 100644 index 000000000..59a9276ce --- /dev/null +++ b/src/state/home-badge.tsx @@ -0,0 +1,24 @@ +import React from 'react' + +type StateContext = boolean +type ApiContext = (hasNew: boolean) => void + +const stateContext = React.createContext<StateContext>(false) +const apiContext = React.createContext<ApiContext>((_: boolean) => {}) + +export function Provider({children}: React.PropsWithChildren<{}>) { + const [state, setState] = React.useState(false) + return ( + <stateContext.Provider value={state}> + <apiContext.Provider value={setState}>{children}</apiContext.Provider> + </stateContext.Provider> + ) +} + +export function useHomeBadge() { + return React.useContext(stateContext) +} + +export function useSetHomeBadge() { + return React.useContext(apiContext) +} |