Remove primary algo references

This commit is contained in:
Eric Bailey
2024-04-23 17:27:37 -05:00
parent dec2f9fdf6
commit afadfb6be6
5 changed files with 16 additions and 67 deletions
@@ -1,26 +0,0 @@
import React from 'react'
import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react'
import {DialogOuterProps} from '#/components/Dialog'
import * as Prompt from '#/components/Prompt'
export function PrimaryAlgoNoticeDialog({
control,
}: {
control: DialogOuterProps['control']
}) {
const {_} = useLingui()
return (
<Prompt.Outer control={control}>
<Prompt.TitleText>Your primary algorithm</Prompt.TitleText>
<Prompt.DescriptionText>
This feed is set as your primary algorithm, which is used as your home
screen when you open the app.
</Prompt.DescriptionText>
<Prompt.Actions>
<Prompt.Cancel cta={_(msg`Close`)} />
</Prompt.Actions>
</Prompt.Outer>
)
}
+7 -8
View File
@@ -1,12 +1,11 @@
export type Gate =
// Keep this alphabetic please.
| 'autoexpand_suggestions_on_profile_follow'
| 'disable_min_shell_on_foregrounding'
| 'disable_poll_on_discover'
| 'autoexpand_suggestions_on_profile_follow_v2'
| 'disable_min_shell_on_foregrounding_v2'
| 'disable_poll_on_discover_v2'
| 'hide_vertical_scroll_indicators'
| 'new_profile_scroll_component'
| 'new_search'
| 'receive_updates'
| 'show_follow_back_label'
| 'show_follow_back_label_v2'
| 'start_session_with_following_v2'
| 'test_gate_1'
| 'test_gate_2'
| 'use_new_suggestions_endpoint'
| 'reduced_onboarding_and_home_algo'
-7
View File
@@ -22,7 +22,6 @@ import {getAgent, useSession} from '#/state/session'
import {router} from '#/routes'
export type FeedSourceFeedInfo = {
isPrimaryAlgorithm: boolean
type: 'feed'
uri: string
route: {
@@ -41,7 +40,6 @@ export type FeedSourceFeedInfo = {
}
export type FeedSourceListInfo = {
isPrimaryAlgorithm: boolean
type: 'list'
uri: string
route: {
@@ -72,7 +70,6 @@ const feedSourceNSIDs = {
export function hydrateFeedGenerator(
view: AppBskyFeedDefs.GeneratorView,
options?: Pick<FeedSourceFeedInfo, 'isPrimaryAlgorithm'>,
): FeedSourceInfo {
const urip = new AtUri(view.uri)
const collection =
@@ -81,7 +78,6 @@ export function hydrateFeedGenerator(
const route = router.matchPath(href)
return {
isPrimaryAlgorithm: options?.isPrimaryAlgorithm ?? false,
type: 'feed',
uri: view.uri,
cid: view.cid,
@@ -113,7 +109,6 @@ export function hydrateList(view: AppBskyGraphDefs.ListView): FeedSourceInfo {
const route = router.matchPath(href)
return {
isPrimaryAlgorithm: false,
type: 'list',
uri: view.uri,
route: {
@@ -209,7 +204,6 @@ export function useSearchPopularFeedsMutation() {
* The following feed, with fallbacks to Discover
*/
const PWI_DISCOVER_FEED_STUB: FeedSourceInfo = {
isPrimaryAlgorithm: true,
type: 'feed',
displayName: 'Discover',
uri: DISCOVER_FEED_URI,
@@ -289,7 +283,6 @@ export function usePinnedFeedsInfos() {
result.push(feedInfo)
} else if (pinnedFeed.type === 'timeline') {
result.push({
isPrimaryAlgorithm: false,
type: 'feed',
displayName: 'Following',
uri: pinnedFeed.value,
+8 -23
View File
@@ -4,7 +4,6 @@ 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
@@ -13,43 +12,29 @@ const stateContext = React.createContext<StateContext>('home')
const setContext = React.createContext<SetContext>((_: string) => {})
function getInitialFeed(gate: (gateName: Gate) => boolean) {
const isPrimaryAlgoExperimentEnabled = gate(
'reduced_onboarding_and_home_algo',
)
let feed = DEFAULT_FEED_DESCRIPTOR
if (isWeb) {
if (window.location.pathname === '/') {
const params = new URLSearchParams(window.location.search)
const feedFromUrl = params.get('feed')
if (feedFromUrl) {
// basically a link to a specific tab, use that every time if present
// If explicitly booted from a link like /?feed=..., prefer that.
return feedFromUrl
}
}
const feedFromSession = sessionStorage.getItem('lastSelectedHomeFeed')
if (feedFromSession) {
// Fall back to a previously chosen feed for this browser tab.
feed = feedFromSession
return feedFromSession
}
}
const feedFromPersisted = persisted.get('lastSelectedHomeFeed')
if (feedFromPersisted) {
// Fall back to the last chosen one across all tabs.
feed = feedFromPersisted
}
if (isPrimaryAlgoExperimentEnabled) {
// following feed
if (feed === 'home') {
return 'home'
if (!gate('start_session_with_following_v2')) {
const feedFromPersisted = persisted.get('lastSelectedHomeFeed')
if (feedFromPersisted) {
// Fall back to the last chosen one across all tabs.
return feedFromPersisted
}
// or left-most tab
return DEFAULT_FEED_DESCRIPTOR
}
return DEFAULT_FEED_DESCRIPTOR
return 'home'
}
export function Provider({children}: React.PropsWithChildren<{}>) {
+1 -3
View File
@@ -26,9 +26,7 @@ export function HomeHeader(
if (!hasSession) return false
return feeds.some(tab => {
const isFollowing = ['home', 'following'].includes(tab.uri)
const isPrimaryAlgo = tab.isPrimaryAlgorithm
const isCustom = !isFollowing && !isPrimaryAlgo
return isCustom
return !isFollowing
})
}, [feeds, hasSession])