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() {