Changed queueMessageSend to use JobQueue.

pull/169/head
Mikunj 6 years ago
parent 8462864373
commit 1d40bc3af9

@ -8,6 +8,7 @@
/* global textsecure: false */ /* global textsecure: false */
/* global Whisper: false */ /* global Whisper: false */
/* global lokiP2pAPI: false */ /* global lokiP2pAPI: false */
/* global JobQueue: false */
/* eslint-disable more/no-then */ /* eslint-disable more/no-then */
@ -160,6 +161,8 @@
// Online status handling // Online status handling
this.set({ isOnline: lokiP2pAPI.isOnline(this.id) }); this.set({ isOnline: lokiP2pAPI.isOnline(this.id) });
this.jobQueue = new JobQueue();
}, },
isMe() { isMe() {
@ -1010,23 +1013,12 @@
}, },
queueMessageSend(callback) { queueMessageSend(callback) {
const previous = this.pendingSend || Promise.resolve();
const taskWithTimeout = textsecure.createTaskWithTimeout( const taskWithTimeout = textsecure.createTaskWithTimeout(
callback, callback,
`conversation ${this.idForLogging()}` `conversation ${this.idForLogging()}`
); );
this.pendingSend = previous.then(taskWithTimeout, taskWithTimeout); return this.jobQueue.add(taskWithTimeout);
const current = this.pendingSend;
current.then(() => {
if (this.pendingSend === current) {
delete this.pendingSend;
}
});
return current;
}, },
getRecipients() { getRecipients() {

Loading…
Cancel
Save