Don't await profile fetches without changes
This commit is contained in:
parent
1ad284d22c
commit
03173a31da
1 changed files with 11 additions and 9 deletions
12
ts/groups.ts
12
ts/groups.ts
|
@ -2942,6 +2942,7 @@ async function updateGroup(
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let profileFetches: Promise<Array<void>> | undefined;
|
||||||
if (contactsWithoutProfileKey.length !== 0) {
|
if (contactsWithoutProfileKey.length !== 0) {
|
||||||
log.info(
|
log.info(
|
||||||
`updateGroup/${logId}: fetching ` +
|
`updateGroup/${logId}: fetching ` +
|
||||||
|
@ -2951,22 +2952,23 @@ async function updateGroup(
|
||||||
const profileFetchQueue = new PQueue({
|
const profileFetchQueue = new PQueue({
|
||||||
concurrency: 3,
|
concurrency: 3,
|
||||||
});
|
});
|
||||||
try {
|
profileFetches = profileFetchQueue.addAll(
|
||||||
await profileFetchQueue.addAll(
|
|
||||||
contactsWithoutProfileKey.map(contact => () => {
|
contactsWithoutProfileKey.map(contact => () => {
|
||||||
const active = contact.getActiveProfileFetch();
|
const active = contact.getActiveProfileFetch();
|
||||||
return active || contact.getProfiles();
|
return active || contact.getProfiles();
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (changeMessagesToSave.length > 0) {
|
||||||
|
try {
|
||||||
|
await profileFetches;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
log.error(
|
log.error(
|
||||||
`updateGroup/${logId}: failed to fetch missing profiles`,
|
`updateGroup/${logId}: failed to fetch missing profiles`,
|
||||||
Errors.toLogFormat(error)
|
Errors.toLogFormat(error)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (changeMessagesToSave.length > 0) {
|
|
||||||
await appendChangeMessages(conversation, changeMessagesToSave);
|
await appendChangeMessages(conversation, changeMessagesToSave);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue