Move suggested follow recommendations to the server (#836)
* Move suggested follow recommendations to the server * fix search results color in dark mode --------- Co-authored-by: Ansh Nanda <anshnanda10@gmail.com>zio/stable
parent
e8843ded5b
commit
ad4eaf5ed2
|
@ -35,67 +35,6 @@ export function TEAM_HANDLES(serviceUrl: string) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE
|
|
||||||
// this is a temporary list that we periodically update
|
|
||||||
// it is used in the search interface if the user doesn't follow anybody
|
|
||||||
// -prf
|
|
||||||
export const PROD_SUGGESTED_FOLLOWS = [
|
|
||||||
'bsky.app',
|
|
||||||
'jay.bsky.team',
|
|
||||||
'pfrazee.com',
|
|
||||||
'why.bsky.team',
|
|
||||||
'dholms.xyz',
|
|
||||||
'emily.bsky.team',
|
|
||||||
'rose.bsky.team',
|
|
||||||
'jack.bsky.social',
|
|
||||||
'faithlove.art',
|
|
||||||
'annaghughes.bsky.social',
|
|
||||||
'astrokatie.com',
|
|
||||||
'whysharksmatter.bsky.social',
|
|
||||||
'jamesgunn.bsky.social',
|
|
||||||
'seangunn.bsky.social',
|
|
||||||
'kumail.bsky.social',
|
|
||||||
'craignewmark.bsky.social',
|
|
||||||
'xychelsea.tv',
|
|
||||||
'catsofyore.bsky.social',
|
|
||||||
'mcq.bsky.social',
|
|
||||||
'mmasnick.bsky.social',
|
|
||||||
'kelseyhightower.com',
|
|
||||||
'aliafonzy.bsky.social',
|
|
||||||
'bradfitz.com',
|
|
||||||
'danabramov.bsky.social',
|
|
||||||
'shinyakato.dev',
|
|
||||||
'karpathy.bsky.social',
|
|
||||||
'lookitup.baby',
|
|
||||||
'pariss.blacktechpipeline.com',
|
|
||||||
'swiftonsecurity.com',
|
|
||||||
'ericajoy.astrel.la',
|
|
||||||
'b0rk.jvns.ca',
|
|
||||||
'vickiboykis.com',
|
|
||||||
'brooke.vibe.camp',
|
|
||||||
'amir.blue',
|
|
||||||
'moskov.bsky.social',
|
|
||||||
'neilhimself.bsky.social',
|
|
||||||
'kylierobison.com',
|
|
||||||
'carnage4life.bsky.social',
|
|
||||||
'lolennui.bsky.social',
|
|
||||||
]
|
|
||||||
export const STAGING_SUGGESTED_FOLLOWS = ['arcalinea', 'paul', 'paul2'].map(
|
|
||||||
handle => `${handle}.staging.bsky.dev`,
|
|
||||||
)
|
|
||||||
export const DEV_SUGGESTED_FOLLOWS = ['alice', 'bob', 'carla'].map(
|
|
||||||
handle => `${handle}.test`,
|
|
||||||
)
|
|
||||||
export function SUGGESTED_FOLLOWS(serviceUrl: string) {
|
|
||||||
if (serviceUrl.includes('localhost')) {
|
|
||||||
return DEV_SUGGESTED_FOLLOWS
|
|
||||||
} else if (serviceUrl.includes('staging')) {
|
|
||||||
return STAGING_SUGGESTED_FOLLOWS
|
|
||||||
} else {
|
|
||||||
return PROD_SUGGESTED_FOLLOWS
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const STAGING_DEFAULT_FEED = (rkey: string) =>
|
export const STAGING_DEFAULT_FEED = (rkey: string) =>
|
||||||
`at://did:plc:wqzurwm3kmaig6e6hnc2gqwo/app.bsky.feed.generator/${rkey}`
|
`at://did:plc:wqzurwm3kmaig6e6hnc2gqwo/app.bsky.feed.generator/${rkey}`
|
||||||
export const PROD_DEFAULT_FEED = (rkey: string) =>
|
export const PROD_DEFAULT_FEED = (rkey: string) =>
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import {makeAutoObservable, runInAction} from 'mobx'
|
import {makeAutoObservable, runInAction} from 'mobx'
|
||||||
import {AppBskyActorDefs} from '@atproto/api'
|
import {AppBskyActorDefs} from '@atproto/api'
|
||||||
import shuffle from 'lodash.shuffle'
|
|
||||||
import {RootStoreModel} from '../root-store'
|
import {RootStoreModel} from '../root-store'
|
||||||
import {cleanError} from 'lib/strings/errors'
|
import {cleanError} from 'lib/strings/errors'
|
||||||
import {bundleAsync} from 'lib/async/bundle'
|
import {bundleAsync} from 'lib/async/bundle'
|
||||||
import {SUGGESTED_FOLLOWS} from 'lib/constants'
|
|
||||||
|
|
||||||
const PAGE_SIZE = 30
|
const PAGE_SIZE = 30
|
||||||
|
|
||||||
|
@ -18,6 +16,7 @@ export class SuggestedActorsModel {
|
||||||
isLoading = false
|
isLoading = false
|
||||||
isRefreshing = false
|
isRefreshing = false
|
||||||
hasLoaded = false
|
hasLoaded = false
|
||||||
|
loadMoreCursor: string | undefined = undefined
|
||||||
error = ''
|
error = ''
|
||||||
hasMore = false
|
hasMore = false
|
||||||
|
|
||||||
|
@ -57,33 +56,39 @@ export class SuggestedActorsModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
loadMore = bundleAsync(async (replace: boolean = false) => {
|
loadMore = bundleAsync(async (replace: boolean = false) => {
|
||||||
if (this.suggestions.length && !replace) {
|
if (replace) {
|
||||||
|
this.hasMore = true
|
||||||
|
this.loadMoreCursor = undefined
|
||||||
|
}
|
||||||
|
if (!this.hasMore) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this._xLoading(replace)
|
this._xLoading(replace)
|
||||||
try {
|
try {
|
||||||
// clone the array so we can mutate it
|
const res = await this.rootStore.agent.app.bsky.actor.getSuggestions({
|
||||||
const actors = [
|
limit: 25,
|
||||||
...SUGGESTED_FOLLOWS(
|
cursor: this.loadMoreCursor,
|
||||||
this.rootStore.session.currentSession?.service || '',
|
|
||||||
),
|
|
||||||
]
|
|
||||||
const res = await this.rootStore.agent.getProfiles({
|
|
||||||
actors: shuffle(actors).splice(0, 25),
|
|
||||||
})
|
})
|
||||||
const {profiles} = res.data
|
const {actors, cursor} = res.data
|
||||||
this.rootStore.me.follows.hydrateProfiles(profiles)
|
this.rootStore.me.follows.hydrateProfiles(actors)
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.suggestions = profiles.filter(profile => {
|
if (replace) {
|
||||||
if (profile.viewer?.following) {
|
this.suggestions = []
|
||||||
return false
|
}
|
||||||
}
|
this.loadMoreCursor = cursor
|
||||||
if (profile.did === this.rootStore.me.did) {
|
this.hasMore = !!cursor
|
||||||
return false
|
this.suggestions = this.suggestions.concat(
|
||||||
}
|
actors.filter(actor => {
|
||||||
return true
|
if (actor.viewer?.following) {
|
||||||
})
|
return false
|
||||||
|
}
|
||||||
|
if (actor.did === this.rootStore.me.did) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
this._xIdle()
|
this._xIdle()
|
||||||
} catch (e: any) {
|
} catch (e: any) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ export const SearchResults = observer(({model}: {model: SearchUIModel}) => {
|
||||||
const renderTabBar = React.useCallback(
|
const renderTabBar = React.useCallback(
|
||||||
(props: RenderTabBarFnProps) => {
|
(props: RenderTabBarFnProps) => {
|
||||||
return (
|
return (
|
||||||
<CenteredView style={[pal.border, styles.tabBar]}>
|
<CenteredView style={[pal.border, pal.view, styles.tabBar]}>
|
||||||
<TabBar
|
<TabBar
|
||||||
items={SECTIONS}
|
items={SECTIONS}
|
||||||
{...props}
|
{...props}
|
||||||
|
@ -128,7 +128,6 @@ const styles = StyleSheet.create({
|
||||||
top: 0,
|
top: 0,
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
backgroundColor: 'white',
|
|
||||||
},
|
},
|
||||||
empty: {
|
empty: {
|
||||||
paddingHorizontal: 14,
|
paddingHorizontal: 14,
|
||||||
|
|
Loading…
Reference in New Issue