From a2fcaac118db98ddf0b028639f4276f417e45d8f Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Tue, 6 Feb 2018 16:28:38 +0300 Subject: www: authenticated user receives all ws messages --- juick-www/src/main/static/scripts.js | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'juick-www/src/main') diff --git a/juick-www/src/main/static/scripts.js b/juick-www/src/main/static/scripts.js index 22a75fac..25e65731 100644 --- a/juick-www/src/main/static/scripts.js +++ b/juick-www/src/main/static/scripts.js @@ -125,18 +125,13 @@ var ws, pageTitle; function initWS() { - var content = document.getElementById('content'); - if (!content) { return; } - var pageMID = content.getAttribute('data-mid'); - if (!pageMID) { return; } - - var url = (window.location.protocol === 'https:' ? 'wss' : 'ws') + ':' - + (typeof juickDebug !== 'undefined' ? - '//ws.juick.com/_replies' : ('//ws.juick.com/' + pageMID)), - hash = document.getElementById('body').getAttribute('data-hash'); - + let url = (window.location.protocol === 'https:' ? 'wss' : 'ws') + ':' + + '//ws.juick.com/'; + let hash = document.getElementById('body').getAttribute('data-hash'); if (hash) { url += '?hash=' + hash; + } else { + url += pageMID; } ws = new WebSocket(url); @@ -192,6 +187,10 @@ function isTreeMode() { } function wsIncomingReply(msg) { + let content = document.getElementById('content'); + if (!content) { return; } + let pageMID = content.getAttribute('data-mid'); + if (!pageMID || pageMID != msg.mid) { return; } let msgNum = '/' + msg.rid; if (msg.replyto > 0) { msgNum += ` ${i18n('message.inReplyTo')} /${msg.replyto}`; -- cgit v1.2.3