Create contacts during processing of group updates

This commit is contained in:
Fedor Indutny 2022-01-27 13:46:31 -08:00 committed by GitHub
parent 6578679166
commit 53a27d022f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 60 additions and 15 deletions

View file

@ -216,6 +216,8 @@ export class ConversationModel extends window.Backbone
// This number is recorded as an optimization and may be out of date.
private newestReceivedAtMarkedRead?: number;
private _activeProfileFetch?: Promise<void>;
override defaults(): Partial<ConversationAttributesType> {
return {
unreadCount: 0,
@ -4648,12 +4650,29 @@ export class ConversationModel extends window.Backbone
const queue = new PQueue({
concurrency: 3,
});
await queue.addAll(
conversations.map(
conversation => () =>
getProfile(conversation.get('uuid'), conversation.get('e164'))
)
);
// Convert Promise<void[]> that is returned by addAll() to Promise<void>
const promise = (async () => {
await queue.addAll(
conversations.map(
conversation => () =>
getProfile(conversation.get('uuid'), conversation.get('e164'))
)
);
})();
this._activeProfileFetch = promise;
try {
await promise;
} finally {
if (this._activeProfileFetch === promise) {
this._activeProfileFetch = undefined;
}
}
}
getActiveProfileFetch(): Promise<void> | undefined {
return this._activeProfileFetch;
}
async setEncryptedProfileName(encryptedName: string): Promise<void> {