From 1e5d69739c43940a62ca049f1162bbae1ed3b8f7 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Fri, 16 Jul 2021 10:43:33 -0700 Subject: [PATCH] waitThenMaybeUpdateGroup: If group is blocked, don't fetch --- ts/groups.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/ts/groups.ts b/ts/groups.ts index 1c7a41680..19110f542 100644 --- a/ts/groups.ts +++ b/ts/groups.ts @@ -2707,14 +2707,20 @@ export async function waitThenMaybeUpdateGroup( options: MaybeUpdatePropsType, { viaSync = false } = {} ): Promise { + 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