From 1d40bc3af9edfa1dc12123d570b87ed532887d23 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Tue, 5 Feb 2019 10:17:11 +1100 Subject: [PATCH 1/3] 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() { From 926362f88a05dcabcf6f1a1cecd2a85a8b653d94 Mon Sep 17 00:00:00 2001 From: Mikunj Date: Tue, 5 Feb 2019 10:20:26 +1100 Subject: [PATCH 2/3] Rename queue_manager to job_queue --- background.html | 2 +- js/{queue_manager.js => job_queue.js} | 0 test/index.html | 1 + 3 files changed, 2 insertions(+), 1 deletion(-) rename js/{queue_manager.js => job_queue.js} (100%) 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/test/index.html b/test/index.html index c541e717b..08c57c08d 100644 --- a/test/index.html +++ b/test/index.html @@ -373,6 +373,7 @@ + From e3c0f2147a8066497d562f7531514e6417c6305f Mon Sep 17 00:00:00 2001 From: Mikunj Date: Tue, 5 Feb 2019 11:12:55 +1100 Subject: [PATCH 3/3] Fixed variable name. --- js/models/conversations.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 7c0f57354..ed26772ca 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -162,7 +162,7 @@ // Online status handling this.set({ isOnline: lokiP2pAPI.isOnline(this.id) }); - this.jobQueue = new JobQueue(); + this.messageSendQueue = new JobQueue(); }, isMe() { @@ -1018,7 +1018,7 @@ `conversation ${this.idForLogging()}` ); - return this.jobQueue.add(taskWithTimeout); + return this.messageSendQueue.add(taskWithTimeout); }, getRecipients() {