Update hardcoded suggested actors (#524)

* Update the hardcoded suggested follows

* Update the suggested actors to just use hardcoded list since there's now the foaf system
zio/stable
Paul Frazee 2023-04-24 18:49:11 -05:00 committed by GitHub
parent c5222db38b
commit df1791bde2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 46 additions and 186 deletions

View File

@ -34,121 +34,42 @@ export function TEAM_HANDLES(serviceUrl: string) {
} }
export const PROD_SUGGESTED_FOLLOWS = [ export const PROD_SUGGESTED_FOLLOWS = [
'christina', 'faithlove.art',
'wesam', 'danielkoeth.bsky.social',
'jim', 'bsky.app',
'ab', 'jay.bsky.team',
'karalabe', 'pfrazee.com',
'clun', 'why.bsky.team',
'staltz', 'support.bsky.team',
'gillian', 'jack.bsky.social',
'karpathy', 'earthquake.bsky.social',
'zoink', 'jamesgunn.bsky.social',
'john', 'seangunn.bsky.social',
'round', 'kumail.bsky.social',
'vex', 'craignewmark.bsky.social',
'umang', 'grimes.bsky.social',
'atroyn', 'xychelsea.tv',
'poisonivy', 'mcq.bsky.social',
'wongmjane', 'mmasnick.bsky.social',
'lari', 'nitasha.bsky.social',
'arunwadhwa', 'kenklippenstein.bsky.social',
'trav', 'jaypeters.bsky.social',
'fred', 'miyagawa.bsky.social',
'offscript', 'anildash.com',
'satnam', 'tiffani.bsky.social',
'ella', 'kelseyhightower.com',
'caspian', 'aliafonzy.bsky.social',
'spencer', 'tszzl.bsky.social',
'nickgrossman', 'danabramov.bsky.social',
'koji', 'shinyakato.dev',
'avy', 'karpathy.bsky.social',
'seymourstein', 'lookitup.baby',
'joelg', 'brooke.vibe.camp',
'stig', 'mollywhite.net',
'rabble', 'amir.blue',
'hunterwalk', 'zoink.bsky.social',
'evan', 'moskov.bsky.social',
'aviral',
'tami',
'generativist',
'gord',
'ninjapleasedj',
'robotics',
'noahjnelson',
'vijay',
'scottbeale',
'daybreakjung',
'shelby',
'joel',
'space',
'rish',
'simon',
'kelly',
'maxbittker',
'sylphrenetic',
'caleb',
'jik',
'james',
'neil',
'tippenein',
'mandel',
'sharding',
'tyler',
'raymond',
'visakanv',
'saz',
'steph',
'ratzlaff',
'beth',
'weisser',
'katherine',
'annagat',
'an',
'kunal',
'josh',
'lurkshark',
'amir',
'amyxzh',
'danielle',
'jack-frazee',
'daniellefong',
'dystopiabreaker',
'morgan',
'vibes',
'cat',
'yuriy',
'alvinreyes',
'skoot',
'patricia',
'ara4n',
'case',
'armand',
'ivan',
'nicholas',
'kelsey',
'ericlee',
'emily',
'jake',
'jennijuju',
'ian5v',
'bnewbold',
'jasmine',
'chris',
'mtclai',
'willscott',
'michael',
'kwkroeger',
'broox',
'iamrosewang',
'jack-morrison',
'pwang',
'martin',
'jack',
'jay',
] ]
.map(handle => `${handle}.bsky.social`)
.concat(['pfrazee.com', 'divy.zone', 'dholms.xyz', 'why.bsky.world'])
export const STAGING_SUGGESTED_FOLLOWS = ['arcalinea', 'paul', 'paul2'].map( export const STAGING_SUGGESTED_FOLLOWS = ['arcalinea', 'paul', 'paul2'].map(
handle => `${handle}.staging.bsky.dev`, handle => `${handle}.staging.bsky.dev`,
) )

View File

@ -19,10 +19,7 @@ export class SuggestedActorsModel {
isRefreshing = false isRefreshing = false
hasLoaded = false hasLoaded = false
error = '' error = ''
hasMore = true hasMore = false
loadMoreCursor?: string
hardCodedSuggestions: SuggestedActor[] | undefined
// data // data
suggestions: SuggestedActor[] = [] suggestions: SuggestedActor[] = []
@ -60,56 +57,10 @@ export class SuggestedActorsModel {
} }
loadMore = bundleAsync(async (replace: boolean = false) => { loadMore = bundleAsync(async (replace: boolean = false) => {
if (!replace && !this.hasMore) { if (this.suggestions.length && !replace) {
return return
} }
if (replace) {
this.hardCodedSuggestions = undefined
}
this._xLoading(replace) this._xLoading(replace)
try {
let items: SuggestedActor[] = this.suggestions
if (replace) {
items = []
this.loadMoreCursor = undefined
}
let res
do {
await this.fetchHardcodedSuggestions()
if (this.hardCodedSuggestions && this.hardCodedSuggestions.length > 0) {
// pull from the hard-coded suggestions
const newItems = this.hardCodedSuggestions.splice(0, this.pageSize)
items = items.concat(newItems)
this.hasMore = true
this.loadMoreCursor = undefined
} else {
// pull from the PDS' algo
res = await this.rootStore.agent.app.bsky.actor.getSuggestions({
limit: this.pageSize,
cursor: this.loadMoreCursor,
})
this.loadMoreCursor = res.data.cursor
this.hasMore = !!this.loadMoreCursor
items = items.concat(
res.data.actors.filter(
actor => !items.find(i => i.did === actor.did),
),
)
}
} while (items.length < this.pageSize && this.hasMore)
runInAction(() => {
this.suggestions = items
})
this._xIdle()
} catch (e: any) {
this._xIdle(e)
}
})
async fetchHardcodedSuggestions() {
if (this.hardCodedSuggestions) {
return
}
try { try {
// clone the array so we can mutate it // clone the array so we can mutate it
const actors = [ const actors = [
@ -117,20 +68,14 @@ export class SuggestedActorsModel {
this.rootStore.session.currentSession?.service || '', this.rootStore.session.currentSession?.service || '',
), ),
] ]
const res = await this.rootStore.agent.getProfiles({
// fetch the profiles in chunks of 25 (the limit allowed by `getProfiles`) actors: shuffle(actors).splice(0, 25),
let profiles: AppBskyActorDefs.ProfileView[] = [] })
do { const {profiles} = res.data
const res = await this.rootStore.agent.getProfiles({
actors: actors.splice(0, 25),
})
profiles = profiles.concat(res.data.profiles)
} while (actors.length)
this.rootStore.me.follows.hydrateProfiles(profiles) this.rootStore.me.follows.hydrateProfiles(profiles)
runInAction(() => { runInAction(() => {
profiles = profiles.filter(profile => { this.suggestions = profiles.filter(profile => {
if (profile.viewer?.following) { if (profile.viewer?.following) {
return false return false
} }
@ -139,18 +84,12 @@ export class SuggestedActorsModel {
} }
return true return true
}) })
this.hardCodedSuggestions = shuffle(profiles)
})
} catch (e) {
this.rootStore.log.error(
'Failed to getProfiles() for suggested follows',
{e},
)
runInAction(() => {
this.hardCodedSuggestions = []
}) })
this._xIdle()
} catch (e: any) {
this._xIdle(e)
} }
} })
// state transitions // state transitions
// = // =