Clarify primary algo usage

This commit is contained in:
Eric Bailey
2024-04-18 10:19:57 -05:00
parent 9351281fd9
commit e02ea9ee26
5 changed files with 16 additions and 9 deletions
+5 -1
View File
@@ -43,8 +43,12 @@ type AuthorFilter =
| 'posts_with_media'
type FeedUri = string
type ListUri = string
/**
* Represents a "not found" state, that results in the left-most tab being
* selected on the Home screen.
*/
export const DEFAULT_FEED_DESCRIPTOR = '__default__'
export type FeedDescriptor =
| 'primary-algo'
| 'home'
| 'following'
| `author|${ActorDid}|${AuthorFilter}`
+6 -3
View File
@@ -4,6 +4,7 @@ import {Gate} from '#/lib/statsig/gates'
import {useGate} from '#/lib/statsig/statsig'
import {isWeb} from '#/platform/detection'
import * as persisted from '#/state/persisted'
import {DEFAULT_FEED_DESCRIPTOR} from '#/state/queries/post-feed'
type StateContext = string
type SetContext = (v: string) => void
@@ -15,7 +16,7 @@ function getInitialFeed(gate: (gateName: Gate) => boolean) {
const isPrimaryAlgoExperimentEnabled = gate(
'reduced_onboarding_and_home_algo',
)
let feed = isPrimaryAlgoExperimentEnabled ? 'primary-algo' : 'home'
let feed = DEFAULT_FEED_DESCRIPTOR
if (isWeb) {
if (window.location.pathname === '/') {
@@ -40,13 +41,15 @@ function getInitialFeed(gate: (gateName: Gate) => boolean) {
}
if (isPrimaryAlgoExperimentEnabled) {
// following feed
if (feed === 'home') {
return 'home'
}
return 'primary-algo'
// or left-most tab
return DEFAULT_FEED_DESCRIPTOR
}
return 'home'
return DEFAULT_FEED_DESCRIPTOR
}
export function Provider({children}: React.PropsWithChildren<{}>) {
+1 -3
View File
@@ -24,9 +24,7 @@ export function HomeHeader(
const hasPinnedCustom = React.useMemo<boolean>(() => {
if (!hasSession) return false
return feeds.some(
tab => !['home', 'primary-algo', 'following'].includes(tab.uri),
)
return feeds.some(tab => !['home', 'following'].includes(tab.uri))
}, [feeds, hasSession])
const items = React.useMemo(() => {
+4
View File
@@ -74,6 +74,10 @@ function HomeScreenReady({
const rawSelectedFeed = useSelectedFeed()
const setSelectedFeed = useSetSelectedFeed()
const maybeFoundIndex = allFeeds.indexOf(rawSelectedFeed as FeedDescriptor)
/*
* N.B. if DEFAULT_FEED_DESCRIPTOR, maybeFoundIndex will be -1 and we'll fall
* back to 0
*/
const selectedIndex = Math.max(0, maybeFoundIndex)
const selectedFeed = allFeeds[selectedIndex]
-2
View File
@@ -36,8 +36,6 @@ export function DesktopFeeds() {
let feed: FeedDescriptor
if (uri === 'home') {
feed = 'home'
} else if (uri === 'primary-algo') {
feed = 'primary-algo'
} else if (uri.includes('app.bsky.feed.generator')) {
feed = `feedgen|${uri}`
} else if (uri.includes('app.bsky.graph.list')) {