getProfiles: Fetch a maximum of three profiles at at a time
This commit is contained in:
parent
d9b951bfcb
commit
02a732c511
1 changed files with 10 additions and 3 deletions
|
@ -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'))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue