From dac4d288a412a4d34ab20572fcc6cba63fc55d10 Mon Sep 17 00:00:00 2001 From: jq-rs Date: Fri, 24 Apr 2020 12:16:28 +0300 Subject: [PATCH] Fix resend handling. --- js/mlestalk.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/js/mlestalk.js b/js/mlestalk.js index 5ecdc3a..404fc30 100644 --- a/js/mlestalk.js +++ b/js/mlestalk.js @@ -105,8 +105,8 @@ function hash_message(uid, data) { return SipHash.hash_hex(gSipKey, uid + data); } -function uidQueueGet(uid) { - return gUidQueue[uid]; +function uidQueueGet(uid, channel) { + return gUidQueue[uid + channel]; } function queueFindAndMatch(msgTimestamp, uid, channel, message) { @@ -155,10 +155,11 @@ function queueSweepAndSend(uid, channel) { } function uidQueuePush(uid, channel, arr) { - if (!gUidQueue[uid+channel]) { - gUidQueue[uid+channel] = new Queue(); + let q = uidQueueGet(uid, channel); + if (!q) { + gUidQueue[uid + channel] = new Queue(); + q = uidQueueGet(uid, channel); } - let q = gUidQueue[uid+channel]; q.push(arr); } @@ -793,7 +794,7 @@ function sendData(cmd, uid, channel, data, isFull, isImage, isMultipart, isFirst gWebWorker.postMessage(arr); } if (gSipKeyIsOk && isFull && data.length > 0) - queuePostMsg(uid, [date, arr, hash_message(uid, data), isImage]); + queuePostMsg(uid, channel, [date, arr, hash_message(uid, data), isImage]); } }