From bd049eddd4fa79d6960746d884fc6f5c8defd8e8 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 19 Nov 2019 09:33:00 +0000 Subject: sse: fix notifications visible for loaded items when the items were loaded before the notifications --- view/js/main.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 19e73c1d2..fec86f4ba 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -30,6 +30,7 @@ var sse_bs_active = false; var sse_offset = 0; var sse_type; var sse_partial_result = false; +var sse_mids; // take care of tab/window reloads on channel change if(localStorage.getItem('uid') !== localUser.toString()) { @@ -310,7 +311,7 @@ function handle_comment_form(e) { ex_form.find('.comment-edit-text').removeClass('expanded').attr('placeholder', aStr.comment); ex_form.find(':not(.comment-edit-text)').hide(); } - i++ + i++; }); } @@ -858,12 +859,15 @@ function updateConvItems(mode,data) { } }); + sse_mids = []; // take care of the notifications count updates $('.thread-wrapper', data).each(function() { var nmid = $(this).data('b64mid'); + sse_mids.push(nmid); + if($('.notification[data-b64mid=\'' + nmid + '\']').length) { $('.notification[data-b64mid=\'' + nmid + '\']').each(function() { var n = this.parentElement.id.split('-'); @@ -893,6 +897,7 @@ function updateConvItems(mode,data) { }); + //console.log(sse_mids); // reset rotators and cursors we may have set before reaching this place @@ -2072,6 +2077,10 @@ function sse_handleNotificationsItems(notifyType, data, replace, followup) { } $(data).each(function() { + if(sse_mids.indexOf(this.b64mid) >= 0) { + console.log('dismiss: ' + this.b64mid); + return true; + } html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.addr,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top,this.unseen,this.private_forum); notify_menu.append(html); }); -- cgit v1.2.3