From 84990c509e9feb0cd44921a318aedcbad92b1da7 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 18 May 2023 15:12:18 -0500 Subject: [PATCH] Drop the hard-coded what's hot algo --- src/state/models/feeds/posts.ts | 56 +------------------ .../com/modals/ContentLanguagesSettings.tsx | 4 +- src/view/com/pager/FeedsTabBar.web.tsx | 7 +-- src/view/com/pager/FeedsTabBarMobile.tsx | 7 +-- ...mptyState.tsx => CustomFeedEmptyState.tsx} | 27 ++++++++- src/view/screens/Home.tsx | 35 ++---------- 6 files changed, 36 insertions(+), 100 deletions(-) rename src/view/com/posts/{WhatsHotEmptyState.tsx => CustomFeedEmptyState.tsx} (69%) diff --git a/src/state/models/feeds/posts.ts b/src/state/models/feeds/posts.ts index dfd92b35..5a5b2878 100644 --- a/src/state/models/feeds/posts.ts +++ b/src/state/models/feeds/posts.ts @@ -310,7 +310,7 @@ export class PostsFeedModel { constructor( public rootStore: RootStoreModel, - public feedType: 'home' | 'author' | 'suggested' | 'goodstuff' | 'custom', + public feedType: 'home' | 'author' | 'suggested' | 'custom', params: | GetTimeline.QueryParams | GetAuthorFeed.QueryParams @@ -391,10 +391,9 @@ export class PostsFeedModel { } get feedTuners() { - if (this.feedType === 'goodstuff') { + if (this.feedType === 'custom') { return [ FeedTuner.dedupReposts, - FeedTuner.likedRepliesOnly, FeedTuner.preferredLangOnly( this.rootStore.preferences.contentLanguages, ), @@ -701,15 +700,6 @@ export class PostsFeedModel { return this.rootStore.agent.app.bsky.feed.getFeed( params as GetCustomFeed.QueryParams, ) - } else if (this.feedType === 'goodstuff') { - const res = await getGoodStuff( - this.rootStore.session.currentSession?.accessJwt || '', - params as GetTimeline.QueryParams, - ) - res.data.feed = (res.data.feed || []).filter( - item => !item.post.author.viewer?.muted, - ) - return res } else { return this.rootStore.agent.getAuthorFeed( params as GetAuthorFeed.QueryParams, @@ -717,45 +707,3 @@ export class PostsFeedModel { } } } - -// HACK -// temporary off-spec route to get the good stuff -// -prf -async function getGoodStuff( - accessJwt: string, - params: GetTimeline.QueryParams, -): Promise { - const controller = new AbortController() - const to = setTimeout(() => controller.abort(), 15e3) - - const uri = new URL('https://bsky.social/xrpc/app.bsky.unspecced.getPopular') - let k: keyof GetTimeline.QueryParams - for (k in params) { - if (typeof params[k] !== 'undefined') { - uri.searchParams.set(k, String(params[k])) - } - } - - const res = await fetch(String(uri), { - method: 'get', - headers: { - accept: 'application/json', - authorization: `Bearer ${accessJwt}`, - }, - signal: controller.signal, - }) - - const resHeaders: Record = {} - res.headers.forEach((value: string, key: string) => { - resHeaders[key] = value - }) - let resBody = await res.json() - - clearTimeout(to) - - return { - success: res.status === 200, - headers: resHeaders, - data: jsonToLex(resBody), - } -} diff --git a/src/view/com/modals/ContentLanguagesSettings.tsx b/src/view/com/modals/ContentLanguagesSettings.tsx index 0c750fe0..700f1cbc 100644 --- a/src/view/com/modals/ContentLanguagesSettings.tsx +++ b/src/view/com/modals/ContentLanguagesSettings.tsx @@ -41,8 +41,8 @@ export function Component({}: {}) { Content Languages - Which languages would you like to see in the What's Hot feed? (Leave - them all unchecked to see any language.) + Which languages would you like to see in the your feed? (Leave them all + unchecked to see any language.) {languages.map(lang => ( diff --git a/src/view/com/pager/FeedsTabBar.web.tsx b/src/view/com/pager/FeedsTabBar.web.tsx index 56ca6f2a..78937611 100644 --- a/src/view/com/pager/FeedsTabBar.web.tsx +++ b/src/view/com/pager/FeedsTabBar.web.tsx @@ -28,12 +28,7 @@ const FeedsTabBarDesktop = observer( ) => { const store = useStores() const items = useMemo( - () => [ - 'Following', - "What's hot", - ...store.me.savedFeeds.pinnedFeedNames, - 'My feeds', - ], + () => ['Following', ...store.me.savedFeeds.pinnedFeedNames, 'My feeds'], [store.me.savedFeeds.pinnedFeedNames], ) const pal = usePalette('default') diff --git a/src/view/com/pager/FeedsTabBarMobile.tsx b/src/view/com/pager/FeedsTabBarMobile.tsx index cb910ccb..a41f0ef3 100644 --- a/src/view/com/pager/FeedsTabBarMobile.tsx +++ b/src/view/com/pager/FeedsTabBarMobile.tsx @@ -33,12 +33,7 @@ export const FeedsTabBar = observer( }, [store]) const items = useMemo( - () => [ - 'Following', - "What's hot", - ...store.me.savedFeeds.pinnedFeedNames, - 'My feeds', - ], + () => ['Following', ...store.me.savedFeeds.pinnedFeedNames, 'My feeds'], [store.me.savedFeeds.pinnedFeedNames], ) diff --git a/src/view/com/posts/WhatsHotEmptyState.tsx b/src/view/com/posts/CustomFeedEmptyState.tsx similarity index 69% rename from src/view/com/posts/WhatsHotEmptyState.tsx rename to src/view/com/posts/CustomFeedEmptyState.tsx index ade94ca3..69dd7990 100644 --- a/src/view/com/posts/WhatsHotEmptyState.tsx +++ b/src/view/com/posts/CustomFeedEmptyState.tsx @@ -1,5 +1,6 @@ import React from 'react' import {StyleSheet, View} from 'react-native' +import {useNavigation} from '@react-navigation/native' import { FontAwesomeIcon, FontAwesomeIconStyle, @@ -7,14 +8,21 @@ import { import {Text} from '../util/text/Text' import {Button} from '../util/forms/Button' import {MagnifyingGlassIcon} from 'lib/icons' +import {NavigationProp} from 'lib/routes/types' import {useStores} from 'state/index' import {usePalette} from 'lib/hooks/usePalette' import {s} from 'lib/styles' -export function WhatsHotEmptyState() { +export function CustomFeedEmptyState() { const pal = usePalette('default') const palInverted = usePalette('inverted') const store = useStores() + const navigation = useNavigation() + + const onPressFindAccounts = React.useCallback(() => { + navigation.navigate('SearchTab') + navigation.popToTop() + }, [navigation]) const onPressSettings = React.useCallback(() => { store.shell.openModal({name: 'content-languages-settings'}) @@ -26,9 +34,22 @@ export function WhatsHotEmptyState() { - Your What's Hot feed is empty! This is because there aren't enough users - posting in your selected language. + This feed is empty! You may need to follow more users or tune your + language settings. +