Refactor contact sync processing

This commit is contained in:
Fedor Indutny 2022-08-24 22:04:42 -07:00 committed by GitHub
parent 76e73f63dc
commit 7ce4beb270
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 229 additions and 156 deletions

View file

@ -4,6 +4,7 @@
import { compact, has, isNumber, throttle, debounce } from 'lodash';
import { batch as batchDispatch } from 'react-redux';
import { v4 as generateGuid } from 'uuid';
import PQueue from 'p-queue';
import type {
ConversationAttributesType,
@ -191,9 +192,9 @@ export class ConversationModel extends window.Backbone
inProgressFetch?: Promise<unknown>;
newMessageQueue?: typeof window.PQueueType;
newMessageQueue?: PQueue;
jobQueue?: typeof window.PQueueType;
jobQueue?: PQueue;
storeName?: string | null;
@ -1313,7 +1314,7 @@ export class ConversationModel extends window.Backbone
private async beforeAddSingleMessage(): Promise<void> {
if (!this.newMessageQueue) {
this.newMessageQueue = new window.PQueue({
this.newMessageQueue = new PQueue({
concurrency: 1,
timeout: durations.MINUTE * 30,
});
@ -3427,7 +3428,7 @@ export class ConversationModel extends window.Backbone
name: string,
callback: (abortSignal: AbortSignal) => Promise<T>
): Promise<T> {
this.jobQueue = this.jobQueue || new window.PQueue({ concurrency: 1 });
this.jobQueue = this.jobQueue || new PQueue({ concurrency: 1 });
const taskWithTimeout = createTaskWithTimeout(
callback,