diff --git a/package.json b/package.json index 66f39cd3ab..bf4b3e6cd5 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "lodash.chunk": "^4.2.0", "lodash.isequal": "^4.5.0", "lodash.omit": "^4.5.0", + "lodash.shuffle": "^4.2.0", "lru_map": "^0.4.1", "mobx": "^6.6.1", "mobx-react-lite": "^3.4.0", @@ -92,6 +93,7 @@ "@types/lodash.chunk": "^4.2.7", "@types/lodash.isequal": "^4.5.6", "@types/lodash.omit": "^4.5.7", + "@types/lodash.shuffle": "^4.2.7", "@types/react-native": "^0.67.3", "@types/react-test-renderer": "^17.0.1", "@typescript-eslint/eslint-plugin": "^5.48.2", diff --git a/src/state/models/suggested-actors-view.ts b/src/state/models/suggested-actors-view.ts index 7fbe25b514..421fb5a187 100644 --- a/src/state/models/suggested-actors-view.ts +++ b/src/state/models/suggested-actors-view.ts @@ -1,5 +1,6 @@ import {makeAutoObservable, runInAction} from 'mobx' import {AppBskyActorProfile as Profile} from '@atproto/api' +import shuffle from 'lodash.shuffle' import {RootStoreModel} from './root-store' import {cleanError} from '../../lib/strings' import {bundleAsync} from '../../lib/async/bundle' @@ -121,6 +122,7 @@ export class SuggestedActorsViewModel { if (this.hardCodedSuggestions) { return } + await this.rootStore.me.follows.fetchIfNeeded() try { // clone the array so we can mutate it const actors = [ @@ -139,7 +141,7 @@ export class SuggestedActorsViewModel { } while (actors.length) runInAction(() => { - this.hardCodedSuggestions = profiles.filter(profile => { + profiles = profiles.filter(profile => { if (this.rootStore.me.follows.isFollowing(profile.did)) { return false } @@ -148,6 +150,7 @@ export class SuggestedActorsViewModel { } return true }) + this.hardCodedSuggestions = shuffle(profiles) }) } catch (e) { this.rootStore.log.error( diff --git a/yarn.lock b/yarn.lock index bb30349f38..19cbbc0d0e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2838,6 +2838,13 @@ dependencies: "@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@*": version "4.14.191" 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" 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: version "4.7.0" resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"