[Experiment] Ignore the persisted tab (#3442)
parent
f03390e4b2
commit
6d3f9397f4
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue