about summary refs log tree commit diff
diff options
context:
space:
mode:
authordan <dan.abramov@gmail.com>2024-04-08 18:39:32 +0100
committerGitHub <noreply@github.com>2024-04-08 18:39:32 +0100
commit6d3f9397f40cf5983a592a33cea9b6d4a086b448 (patch)
tree9d66e13bd95be5b85c6b389f911e25fcc70d09c7
parentf03390e4b2eb8d89ebaca96e6381ff2e7605a57f (diff)
downloadvoidsky-6d3f9397f40cf5983a592a33cea9b6d4a086b448.tar.zst
[Experiment] Ignore the persisted tab (#3442)
-rw-r--r--src/state/shell/selected-feed.tsx21
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)