diff --git a/background.html b/background.html index 7fa85684e..7f85a30d1 100644 --- a/background.html +++ b/background.html @@ -723,7 +723,7 @@ - + diff --git a/js/queue_manager.js b/js/job_queue.js similarity index 100% rename from js/queue_manager.js rename to js/job_queue.js diff --git a/js/models/conversations.js b/js/models/conversations.js index 3191f3319..ed26772ca 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.messageSendQueue = 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.messageSendQueue.add(taskWithTimeout); }, getRecipients() { diff --git a/test/index.html b/test/index.html index c541e717b..08c57c08d 100644 --- a/test/index.html +++ b/test/index.html @@ -373,6 +373,7 @@ +