From 1d40bc3af9edfa1dc12123d570b87ed532887d23 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Tue, 5 Feb 2019 10:17:11 +1100 Subject: [PATCH] Changed queueMessageSend to use JobQueue. --- js/models/conversations.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 3191f3319..7c0f57354 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -8,6 +8,7 @@ /* global textsecure: false */ /* global Whisper: false */ /* global lokiP2pAPI: false */ +/* global JobQueue: false */ /* eslint-disable more/no-then */ @@ -160,6 +161,8 @@ // Online status handling this.set({ isOnline: lokiP2pAPI.isOnline(this.id) }); + + this.jobQueue = new JobQueue(); }, isMe() { @@ -1010,23 +1013,12 @@ }, queueMessageSend(callback) { - const previous = this.pendingSend || Promise.resolve(); - const taskWithTimeout = textsecure.createTaskWithTimeout( callback, `conversation ${this.idForLogging()}` ); - this.pendingSend = previous.then(taskWithTimeout, taskWithTimeout); - const current = this.pendingSend; - - current.then(() => { - if (this.pendingSend === current) { - delete this.pendingSend; - } - }); - - return current; + return this.jobQueue.add(taskWithTimeout); }, getRecipients() {