Randomize hard-coded suggested follows (#226)
* Ensure follows are loaded before filtering hardcoded suggestions * Randomize hard-coded suggested profiles (close #219)
This commit is contained in:
@@ -41,6 +41,7 @@
|
|||||||
"lodash.chunk": "^4.2.0",
|
"lodash.chunk": "^4.2.0",
|
||||||
"lodash.isequal": "^4.5.0",
|
"lodash.isequal": "^4.5.0",
|
||||||
"lodash.omit": "^4.5.0",
|
"lodash.omit": "^4.5.0",
|
||||||
|
"lodash.shuffle": "^4.2.0",
|
||||||
"lru_map": "^0.4.1",
|
"lru_map": "^0.4.1",
|
||||||
"mobx": "^6.6.1",
|
"mobx": "^6.6.1",
|
||||||
"mobx-react-lite": "^3.4.0",
|
"mobx-react-lite": "^3.4.0",
|
||||||
@@ -92,6 +93,7 @@
|
|||||||
"@types/lodash.chunk": "^4.2.7",
|
"@types/lodash.chunk": "^4.2.7",
|
||||||
"@types/lodash.isequal": "^4.5.6",
|
"@types/lodash.isequal": "^4.5.6",
|
||||||
"@types/lodash.omit": "^4.5.7",
|
"@types/lodash.omit": "^4.5.7",
|
||||||
|
"@types/lodash.shuffle": "^4.2.7",
|
||||||
"@types/react-native": "^0.67.3",
|
"@types/react-native": "^0.67.3",
|
||||||
"@types/react-test-renderer": "^17.0.1",
|
"@types/react-test-renderer": "^17.0.1",
|
||||||
"@typescript-eslint/eslint-plugin": "^5.48.2",
|
"@typescript-eslint/eslint-plugin": "^5.48.2",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import {makeAutoObservable, runInAction} from 'mobx'
|
import {makeAutoObservable, runInAction} from 'mobx'
|
||||||
import {AppBskyActorProfile as Profile} from '@atproto/api'
|
import {AppBskyActorProfile as Profile} from '@atproto/api'
|
||||||
|
import shuffle from 'lodash.shuffle'
|
||||||
import {RootStoreModel} from './root-store'
|
import {RootStoreModel} from './root-store'
|
||||||
import {cleanError} from '../../lib/strings'
|
import {cleanError} from '../../lib/strings'
|
||||||
import {bundleAsync} from '../../lib/async/bundle'
|
import {bundleAsync} from '../../lib/async/bundle'
|
||||||
@@ -121,6 +122,7 @@ export class SuggestedActorsViewModel {
|
|||||||
if (this.hardCodedSuggestions) {
|
if (this.hardCodedSuggestions) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
await this.rootStore.me.follows.fetchIfNeeded()
|
||||||
try {
|
try {
|
||||||
// clone the array so we can mutate it
|
// clone the array so we can mutate it
|
||||||
const actors = [
|
const actors = [
|
||||||
@@ -139,7 +141,7 @@ export class SuggestedActorsViewModel {
|
|||||||
} while (actors.length)
|
} while (actors.length)
|
||||||
|
|
||||||
runInAction(() => {
|
runInAction(() => {
|
||||||
this.hardCodedSuggestions = profiles.filter(profile => {
|
profiles = profiles.filter(profile => {
|
||||||
if (this.rootStore.me.follows.isFollowing(profile.did)) {
|
if (this.rootStore.me.follows.isFollowing(profile.did)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -148,6 +150,7 @@ export class SuggestedActorsViewModel {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
this.hardCodedSuggestions = shuffle(profiles)
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.rootStore.log.error(
|
this.rootStore.log.error(
|
||||||
|
|||||||
@@ -2838,6 +2838,13 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@types/lodash" "*"
|
"@types/lodash" "*"
|
||||||
|
|
||||||
|
"@types/lodash.shuffle@^4.2.7":
|
||||||
|
version "4.2.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/lodash.shuffle/-/lodash.shuffle-4.2.7.tgz#b714d829af948a266b0df1477d629c70de2f4c72"
|
||||||
|
integrity sha512-b+K0NBpB4WcNoQTfifuTmi5nm5mJXRw9DBdbFfBr1q1+EVoTKkClDxq/7r1sq2GZcRelMFRsFcGGHrHQgxRySg==
|
||||||
|
dependencies:
|
||||||
|
"@types/lodash" "*"
|
||||||
|
|
||||||
"@types/lodash@*":
|
"@types/lodash@*":
|
||||||
version "4.14.191"
|
version "4.14.191"
|
||||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.191.tgz#09511e7f7cba275acd8b419ddac8da9a6a79e2fa"
|
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.191.tgz#09511e7f7cba275acd8b419ddac8da9a6a79e2fa"
|
||||||
@@ -8990,6 +8997,11 @@ lodash.once@^4.0.0:
|
|||||||
resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac"
|
resolved "https://registry.yarnpkg.com/lodash.once/-/lodash.once-4.1.1.tgz#0dd3971213c7c56df880977d504c88fb471a97ac"
|
||||||
integrity sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==
|
integrity sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==
|
||||||
|
|
||||||
|
lodash.shuffle@^4.2.0:
|
||||||
|
version "4.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/lodash.shuffle/-/lodash.shuffle-4.2.0.tgz#145b5053cf875f6f5c2a33f48b6e9948c6ec7b4b"
|
||||||
|
integrity sha512-V/rTAABKLFjoecTZjKSv+A1ZomG8hZg8hlgeG6wwQVD9AGv+10zqqSf6mFq2tVA703Zd5R0YhSuSlXA+E/Ei+Q==
|
||||||
|
|
||||||
lodash.sortby@^4.7.0:
|
lodash.sortby@^4.7.0:
|
||||||
version "4.7.0"
|
version "4.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
|
resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
|
||||||
|
|||||||
Reference in New Issue
Block a user