aboutsummaryrefslogtreecommitdiffstats
path: root/view/tpl
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2021-07-16 13:48:35 +0200
committerMario Vavti <mario@mariovavti.com>2021-07-16 13:48:35 +0200
commit4f15c0880557ce880a6b119ac244a57258d50e60 (patch)
tree728f3af8709ea069ffc16f95eddac9e53201f35e /view/tpl
parent7b2f4b08145ec31f0150544891633db2f5061104 (diff)
downloadvolse-hubzilla-4f15c0880557ce880a6b119ac244a57258d50e60.tar.gz
volse-hubzilla-4f15c0880557ce880a6b119ac244a57258d50e60.tar.bz2
volse-hubzilla-4f15c0880557ce880a6b119ac244a57258d50e60.zip
more work on moving notifications handling from main.js to the notifications widget
Diffstat (limited to 'view/tpl')
-rw-r--r--view/tpl/notifications_widget.tpl47
1 files changed, 46 insertions, 1 deletions
diff --git a/view/tpl/notifications_widget.tpl b/view/tpl/notifications_widget.tpl
index 5cbfcc214..2a4651c99 100644
--- a/view/tpl/notifications_widget.tpl
+++ b/view/tpl/notifications_widget.tpl
@@ -137,6 +137,18 @@
}
});
+ $(document).on('hz:sse_setNotificationsStatus', function(e, data) {
+ sse_setNotificationsStatus(data);
+ });
+
+ $(document).on('hz:sse_bs_init', function() {
+ sse_bs_init();
+ });
+
+ $(document).on('hz:sse_bs_counts', function() {
+ sse_bs_counts();
+ });
+
});
{{foreach $notifications as $notification}}
@@ -421,7 +433,7 @@
}
- function sse_setNotificationsStatus() {
+ function sse_setNotificationsStatus(data) {
var primary_notifications = ['dm', 'home', 'intros', 'register', 'notify', 'files'];
var secondary_notifications = ['network', 'forums', 'all_events', 'pubs'];
var all_notifications = primary_notifications.concat(secondary_notifications);
@@ -458,6 +470,39 @@
$('#notifications').hide();
}
+ if (typeof data !== typeof undefined) {
+ data.forEach(function(nmid, index) {
+
+ sse_rmids.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);
+ });
+ }
+
+ // 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();
+ }
+ });
+ });
+ }
+
}
function sse_fallback() {