getProfiles: Fetch a maximum of three profiles at at a time

This commit is contained in:
Scott Nonnenberg 2022-01-11 11:40:20 -08:00 committed by GitHub
parent d9b951bfcb
commit 02a732c511
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -4,6 +4,8 @@
/* eslint-disable camelcase */
import { compact, isNumber } from 'lodash';
import { batch as batchDispatch } from 'react-redux';
import PQueue from 'p-queue';
import type {
ConversationAttributesType,
ConversationModelCollectionType,
@ -4624,9 +4626,14 @@ export class ConversationModel extends window.Backbone
// request all conversation members' keys
const conversations =
this.getMembers() as unknown as Array<ConversationModel>;
await Promise.all(
window._.map(conversations, conversation =>
getProfile(conversation.get('uuid'), conversation.get('e164'))
const queue = new PQueue({
concurrency: 3,
});
await queue.addAll(
conversations.map(
conversation => () =>
getProfile(conversation.get('uuid'), conversation.get('e164'))
)
);
}