aboutsummaryrefslogtreecommitdiffstats
path: root/view/js/main.js
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2020-01-14 13:34:56 -0800
committerzotlabs <mike@macgirvin.com>2020-01-14 13:34:56 -0800
commit293d411efb28b8f20a0208e3c52883e9fbb8cea7 (patch)
treea8b0af66015815d56342daf8301ab5ae095eda0a /view/js/main.js
parent2a287e6def5ab54037222c963ab0875faf62fc1a (diff)
parentd96f4340e80207a29a5c1c49cae8c25e3934d5ae (diff)
downloadvolse-hubzilla-293d411efb28b8f20a0208e3c52883e9fbb8cea7.tar.gz
volse-hubzilla-293d411efb28b8f20a0208e3c52883e9fbb8cea7.tar.bz2
volse-hubzilla-293d411efb28b8f20a0208e3c52883e9fbb8cea7.zip
Merge branch 'dev' of https://framagit.org/hubzilla/core into dev
Diffstat (limited to 'view/js/main.js')
-rw-r--r--view/js/main.js46
1 files changed, 27 insertions, 19 deletions
diff --git a/view/js/main.js b/view/js/main.js
index 1baf1ca1f..4ec7a71aa 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -30,7 +30,6 @@ 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()) {
@@ -696,18 +695,36 @@ function updateConvItems(mode,data) {
// take care of the notifications count updates
$('.thread-wrapper', data).each(function() {
- //var nmid = $(this).data('b64mid');
var nmids = $(this).data('b64mids');
nmids.forEach(function(nmid, index) {
- sse_mids.push(nmid);
if($('.notification[data-b64mid=\'' + nmid + '\']').length) {
$('.notification[data-b64mid=\'' + nmid + '\']').each(function() {
var n = this.parentElement.id.split('-');
- return sse_updateNotifications(n[1], nmid, true);
+ return sse_updateNotifications(n[1], nmid);
});
- sse_mids = [];
}
+
+ // special handling for forum notifications
+ $('.notification-forum').filter(function() {
+ var fmids = decodeURIComponent($(this).data('b64mids'));
+ var n = this.parentElement.id.split('-');
+ if(fmids.indexOf(nmid) > -1) {
+ var fcount = Number($('.' + n[1] + '-update').html());
+ fcount--;
+ $('.' + n[1] + '-update').html(fcount);
+ if(fcount < 1)
+ $('.' + n[1] + '-button').fadeOut();
+
+ var count = Number($(this).find('.badge-secondary').html());
+ count--;
+ $(this).find('.badge-secondary').html(count);
+ if(count < 1)
+ $(this).remove();
+ }
+ });
+
+
});
sse_setNotificationsStatus();
@@ -805,7 +822,6 @@ function scrollToItem() {
$('html, body').animate({ scrollTop: $(this).offset().top - $('nav').outerHeight(true) }, 'slow');
$(this).addClass('item-highlight');
}
-
});
}
@@ -1743,7 +1759,7 @@ function sse_handleNotifications(obj, replace, followup) {
}
function sse_handleNotificationsItems(notifyType, data, replace, followup) {
- var notifications_tpl = ((notifyType == 'forums') ? unescape($("#nav-notifications-forums-template[rel=template]").html()) : unescape($("#nav-notifications-template[rel=template]").html()));
+ var notifications_tpl = ((notifyType == 'forums') ? decodeURIComponent($("#nav-notifications-forums-template[rel=template]").html()) : decodeURIComponent($("#nav-notifications-template[rel=template]").html()));
var notify_menu = $("#nav-" + notifyType + "-menu");
var notify_loading = $("#nav-" + notifyType + "-loading");
var notify_count = $("." + notifyType + "-update");
@@ -1754,15 +1770,10 @@ function sse_handleNotificationsItems(notifyType, data, replace, followup) {
}
$(data).each(function() {
- if(sse_mids.indexOf(this.b64mid) >= 0) {
- return sse_updateNotifications(notifyType, this.b64mid, false);
- }
- 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);
+ 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, encodeURIComponent(this.mids));
notify_menu.append(html);
});
- sse_mids = [];
-
if(!replace && !followup) {
$("#nav-" + notifyType + "-menu .notification").sort(function(a,b) {
a = new Date(a.dataset.when);
@@ -1794,9 +1805,7 @@ function sse_handleNotificationsItems(notifyType, data, replace, followup) {
}
}
-function sse_updateNotifications(type, mid, interactive) {
-
- //console.log('interactive: ' + interactive);
+function sse_updateNotifications(type, mid) {
if(type === 'pubs')
return true;
@@ -1818,9 +1827,6 @@ function sse_updateNotifications(type, mid, interactive) {
$('.' + type + '-update').html(count);
}
- if(! interactive)
- return true;
-
$('#nav-' + type + '-menu .notification[data-b64mid=\'' + mid + '\']').fadeOut(function() {
this.remove();
});
@@ -1855,10 +1861,12 @@ function sse_setNotificationsStatus() {
if(any_available) {
$('.notifications-btn').css('opacity', 1);
$('#no_notifications').hide();
+ $('#notifications').show();
}
else {
$('.notifications-btn').css('opacity', 0.5);
$('#navbar-collapse-1').removeClass('show');
$('#no_notifications').show();
+ $('#notifications').hide();
}
}