diff options
author | dan <dan.abramov@gmail.com> | 2024-04-08 18:39:32 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-08 18:39:32 +0100 |
commit | 6d3f9397f40cf5983a592a33cea9b6d4a086b448 (patch) | |
tree | 9d66e13bd95be5b85c6b389f911e25fcc70d09c7 /src/state/shell/selected-feed.tsx | |
parent | f03390e4b2eb8d89ebaca96e6381ff2e7605a57f (diff) | |
download | voidsky-6d3f9397f40cf5983a592a33cea9b6d4a086b448.tar.zst |
[Experiment] Ignore the persisted tab (#3442)
Diffstat (limited to 'src/state/shell/selected-feed.tsx')
-rw-r--r-- | src/state/shell/selected-feed.tsx | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/src/state/shell/selected-feed.tsx b/src/state/shell/selected-feed.tsx index a05d8661b..5c0ac0b02 100644 --- a/src/state/shell/selected-feed.tsx +++ b/src/state/shell/selected-feed.tsx @@ -1,6 +1,8 @@ import React from 'react' -import * as persisted from '#/state/persisted' + +import {useGate} from '#/lib/statsig/statsig' import {isWeb} from '#/platform/detection' +import * as persisted from '#/state/persisted' type StateContext = string type SetContext = (v: string) => void @@ -8,7 +10,7 @@ type SetContext = (v: string) => void const stateContext = React.createContext<StateContext>('home') const setContext = React.createContext<SetContext>((_: string) => {}) -function getInitialFeed() { +function getInitialFeed(startSessionWithFollowing: boolean) { if (isWeb) { if (window.location.pathname === '/') { const params = new URLSearchParams(window.location.search) @@ -24,16 +26,21 @@ function getInitialFeed() { return feedFromSession } } - const feedFromPersisted = persisted.get('lastSelectedHomeFeed') - if (feedFromPersisted) { - // Fall back to the last chosen one across all tabs. - return feedFromPersisted + if (!startSessionWithFollowing) { + const feedFromPersisted = persisted.get('lastSelectedHomeFeed') + if (feedFromPersisted) { + // Fall back to the last chosen one across all tabs. + return feedFromPersisted + } } return 'home' } export function Provider({children}: React.PropsWithChildren<{}>) { - const [state, setState] = React.useState(getInitialFeed) + const startSessionWithFollowing = useGate('start_session_with_following') + const [state, setState] = React.useState(() => + getInitialFeed(startSessionWithFollowing), + ) const saveState = React.useCallback((feed: string) => { setState(feed) |