Don't process edits until attachmentDownloadQueue finishes
This commit is contained in:
parent
5ccb3af040
commit
6906e39c87
3 changed files with 796 additions and 541 deletions
|
@ -11,11 +11,20 @@ const MAX_ATTACHMENT_MSGS_TO_DOWNLOAD = 250;
|
|||
|
||||
let isEnabled = true;
|
||||
let attachmentDownloadQueue: Array<MessageModel> | undefined = [];
|
||||
const queueEmptyCallbacks: Set<() => void> = new Set();
|
||||
|
||||
export function shouldUseAttachmentDownloadQueue(): boolean {
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
export function isAttachmentDownloadQueueEmpty(): boolean {
|
||||
return !(attachmentDownloadQueue ?? []).length;
|
||||
}
|
||||
|
||||
export function registerQueueEmptyCallback(callback: () => void): void {
|
||||
queueEmptyCallbacks.add(callback);
|
||||
}
|
||||
|
||||
export function addToAttachmentDownloadQueue(
|
||||
idLog: string,
|
||||
message: MessageModel
|
||||
|
@ -71,4 +80,6 @@ export async function flushAttachmentDownloadQueue(): Promise<void> {
|
|||
});
|
||||
|
||||
attachmentDownloadQueue = undefined;
|
||||
queueEmptyCallbacks.forEach(callback => callback());
|
||||
queueEmptyCallbacks.clear();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue