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,
|
options: MaybeUpdatePropsType,
|
||||||
{ viaSync = false } = {}
|
{ viaSync = false } = {}
|
||||||
): Promise<void> {
|
): 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
|
// First wait to process all incoming messages on the websocket
|
||||||
await window.waitForEmptyEventQueue();
|
await window.waitForEmptyEventQueue();
|
||||||
|
|
||||||
// Then wait to process all outstanding messages for this conversation
|
// Then make sure we haven't fetched this group too recently
|
||||||
const { conversation } = options;
|
|
||||||
|
|
||||||
const { lastSuccessfulGroupFetch = 0 } = conversation;
|
const { lastSuccessfulGroupFetch = 0 } = conversation;
|
||||||
|
|
||||||
if (isMoreRecentThan(lastSuccessfulGroupFetch, FIVE_MINUTES)) {
|
if (isMoreRecentThan(lastSuccessfulGroupFetch, FIVE_MINUTES)) {
|
||||||
const waitTime = lastSuccessfulGroupFetch + FIVE_MINUTES - Date.now();
|
const waitTime = lastSuccessfulGroupFetch + FIVE_MINUTES - Date.now();
|
||||||
window.log.info(
|
window.log.info(
|
||||||
|
@ -2724,6 +2730,7 @@ export async function waitThenMaybeUpdateGroup(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Then wait to process all outstanding messages for this conversation
|
||||||
await conversation.queueJob('waitThenMaybeUpdateGroup', async () => {
|
await conversation.queueJob('waitThenMaybeUpdateGroup', async () => {
|
||||||
try {
|
try {
|
||||||
// And finally try to update the group
|
// And finally try to update the group
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue