waitThenMaybeUpdateGroup: If group is blocked, don't fetch
This commit is contained in:
parent
8a413beaf2
commit
1e5d69739c
1 changed files with 11 additions and 4 deletions
15
ts/groups.ts
15
ts/groups.ts
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue