waitThenMaybeUpdateGroup: If group is blocked, don't fetch

This commit is contained in:
Scott Nonnenberg 2021-07-16 10:43:33 -07:00 committed by GitHub
parent 8a413beaf2
commit 1e5d69739c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2707,14 +2707,20 @@ export async function waitThenMaybeUpdateGroup(
options: MaybeUpdatePropsType,
{ viaSync = false } = {}
): Promise<void> {
const { conversation } = options;
if (conversation.isBlocked()) {
window.log.info(
`waitThenMaybeUpdateGroup: Group ${conversation.idForLogging()} is blocked, returning early`
);
return;
}
// First wait to process all incoming messages on the websocket
await window.waitForEmptyEventQueue();
// Then wait to process all outstanding messages for this conversation
const { conversation } = options;
// Then make sure we haven't fetched this group too recently
const { lastSuccessfulGroupFetch = 0 } = conversation;
if (isMoreRecentThan(lastSuccessfulGroupFetch, FIVE_MINUTES)) {
const waitTime = lastSuccessfulGroupFetch + FIVE_MINUTES - Date.now();
window.log.info(
@ -2724,6 +2730,7 @@ export async function waitThenMaybeUpdateGroup(
return;
}
// Then wait to process all outstanding messages for this conversation
await conversation.queueJob('waitThenMaybeUpdateGroup', async () => {
try {
// And finally try to update the group