diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-04-25 20:47:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-25 20:47:37 -0500 |
commit | 9b86cb5c36da993c99dfa36760667bded4c71b15 (patch) | |
tree | cdaa505b1c91682b31a995f80087d41ce1025c69 /src/state/models/feeds/notifications.ts | |
parent | f33a355a1ac1fb3e3d91e7e55a9fe9df53313e66 (diff) | |
download | voidsky-9b86cb5c36da993c99dfa36760667bded4c71b15.tar.zst |
Fix: dont request more than 25 posts at a time (close [APP-561]) (#534)
Diffstat (limited to 'src/state/models/feeds/notifications.ts')
-rw-r--r-- | src/state/models/feeds/notifications.ts | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/state/models/feeds/notifications.ts b/src/state/models/feeds/notifications.ts index 0bbbe215c..220e04bce 100644 --- a/src/state/models/feeds/notifications.ts +++ b/src/state/models/feeds/notifications.ts @@ -10,6 +10,7 @@ import { ComAtprotoLabelDefs, } from '@atproto/api' import AwaitLock from 'await-lock' +import chunk from 'lodash.chunk' import {bundleAsync} from 'lib/async/bundle' import {RootStoreModel} from '../root-store' import {PostThreadModel} from '../content/post-thread' @@ -554,10 +555,15 @@ export class NotificationsFeedModel { // fetch additional data if (addedPostMap.size > 0) { - const postsRes = await this.rootStore.agent.app.bsky.feed.getPosts({ - uris: Array.from(addedPostMap.keys()), - }) - for (const post of postsRes.data.posts) { + const uriChunks = chunk(Array.from(addedPostMap.keys()), 25) + const postsChunks = await Promise.all( + uriChunks.map(uris => + this.rootStore.agent.app.bsky.feed + .getPosts({uris}) + .then(res => res.data.posts), + ), + ) + for (const post of postsChunks.flat()) { const models = addedPostMap.get(post.uri) if (models?.length) { for (const model of models) { |