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' | 'posts_with_media'
type FeedUri = string type FeedUri = string
type ListUri = 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 = export type FeedDescriptor =
| 'primary-algo'
| 'home' | 'home'
| 'following' | 'following'
| `author|${ActorDid}|${AuthorFilter}` | `author|${ActorDid}|${AuthorFilter}`
+6 -3
View File
@@ -4,6 +4,7 @@ import {Gate} from '#/lib/statsig/gates'
import {useGate} from '#/lib/statsig/statsig' import {useGate} from '#/lib/statsig/statsig'
import {isWeb} from '#/platform/detection' import {isWeb} from '#/platform/detection'
import * as persisted from '#/state/persisted' import * as persisted from '#/state/persisted'
import {DEFAULT_FEED_DESCRIPTOR} from '#/state/queries/post-feed'
type StateContext = string type StateContext = string
type SetContext = (v: string) => void type SetContext = (v: string) => void
@@ -15,7 +16,7 @@ function getInitialFeed(gate: (gateName: Gate) => boolean) {
const isPrimaryAlgoExperimentEnabled = gate( const isPrimaryAlgoExperimentEnabled = gate(
'reduced_onboarding_and_home_algo', 'reduced_onboarding_and_home_algo',
) )
let feed = isPrimaryAlgoExperimentEnabled ? 'primary-algo' : 'home' let feed = DEFAULT_FEED_DESCRIPTOR
if (isWeb) { if (isWeb) {
if (window.location.pathname === '/') { if (window.location.pathname === '/') {
@@ -40,13 +41,15 @@ function getInitialFeed(gate: (gateName: Gate) => boolean) {
} }
if (isPrimaryAlgoExperimentEnabled) { if (isPrimaryAlgoExperimentEnabled) {
// following feed
if (feed === 'home') { if (feed === 'home') {
return '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<{}>) { export function Provider({children}: React.PropsWithChildren<{}>) {
+1 -3
View File
@@ -24,9 +24,7 @@ export function HomeHeader(
const hasPinnedCustom = React.useMemo<boolean>(() => { const hasPinnedCustom = React.useMemo<boolean>(() => {
if (!hasSession) return false if (!hasSession) return false
return feeds.some( return feeds.some(tab => !['home', 'following'].includes(tab.uri))
tab => !['home', 'primary-algo', 'following'].includes(tab.uri),
)
}, [feeds, hasSession]) }, [feeds, hasSession])
const items = React.useMemo(() => { const items = React.useMemo(() => {
+4
View File
@@ -74,6 +74,10 @@ function HomeScreenReady({
const rawSelectedFeed = useSelectedFeed() const rawSelectedFeed = useSelectedFeed()
const setSelectedFeed = useSetSelectedFeed() const setSelectedFeed = useSetSelectedFeed()
const maybeFoundIndex = allFeeds.indexOf(rawSelectedFeed as FeedDescriptor) 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 selectedIndex = Math.max(0, maybeFoundIndex)
const selectedFeed = allFeeds[selectedIndex] const selectedFeed = allFeeds[selectedIndex]
-2
View File
@@ -36,8 +36,6 @@ export function DesktopFeeds() {
let feed: FeedDescriptor let feed: FeedDescriptor
if (uri === 'home') { if (uri === 'home') {
feed = 'home' feed = 'home'
} else if (uri === 'primary-algo') {
feed = 'primary-algo'
} else if (uri.includes('app.bsky.feed.generator')) { } else if (uri.includes('app.bsky.feed.generator')) {
feed = `feedgen|${uri}` feed = `feedgen|${uri}`
} else if (uri.includes('app.bsky.graph.list')) { } else if (uri.includes('app.bsky.graph.list')) {