From 36a57b4007724ebec58b495ff0071c2d4b36fa9f Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 17 Jul 2019 10:49:26 +0200 Subject: [PATCH 1/2] Fix duplicate notifications n reconnect --- www/common/outer/mailbox.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js index 08e7b9351..e5397f7bc 100644 --- a/www/common/outer/mailbox.js +++ b/www/common/outer/mailbox.js @@ -245,8 +245,11 @@ proxy.mailboxes = { }); box.queue = []; }; + var lastReceivedHash; // Don't send a duplicate of the last known hash on reconnect box.onMessage = cfg.onMessage = function (msg, user, vKey, isCp, hash, author) { if (hash === m.lastKnownHash) { return; } + if (hash === lastReceivedHash) { return; } + lastReceivedHash = hash; try { msg = JSON.parse(msg); } catch (e) { @@ -364,6 +367,7 @@ proxy.mailboxes = { txid: txid, complete: true }, [req.cId]); + delete ctx.req[txid]; } }); }; From eee040a8680bf8b8000c4e715ce274f9a614edbd Mon Sep 17 00:00:00 2001 From: yflory Date: Wed, 17 Jul 2019 10:50:51 +0200 Subject: [PATCH 2/2] Fix 'req is undefined' --- www/common/outer/mailbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/www/common/outer/mailbox.js b/www/common/outer/mailbox.js index e5397f7bc..081f64cc3 100644 --- a/www/common/outer/mailbox.js +++ b/www/common/outer/mailbox.js @@ -342,10 +342,10 @@ proxy.mailboxes = { var txid = parsed[1]; var req = ctx.req[txid]; + if (!req) { return; } var type = parsed[0]; var _msg = parsed[2]; var box = req.box; - if (!req) { return; } if (type === 'HISTORY_RANGE') { if (!Array.isArray(_msg)) { return; }