From db0a3a753420e8722776094334759dd4ff61fc77 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 2 Jun 2018 15:39:38 +0200 Subject: some more work on forum notifications --- Zotlabs/Module/Ping.php | 13 +++++++++++++ Zotlabs/Widget/Notifications.php | 8 ++------ view/js/main.js | 21 +++++++++++++++++++-- view/theme/redbasic/css/style.css | 8 +++++++- view/tpl/notifications_widget.tpl | 13 ++++++++++++- 5 files changed, 53 insertions(+), 10 deletions(-) diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index a43d9863e..941b7b286 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -673,14 +673,27 @@ class Ping extends \Zotlabs\Web\Controller { dbesc($r1[$x]['xchan_hash']) ); if($r[0]['unseen']) { + $r1[$x]['notify_link'] = z_root() . '/network/?f=&cid=' . $r1[$x]['abook_id']; + $r1[$x]['name'] = $r1[$x]['xchan_name']; + $r1[$x]['url'] = $r1[$x]['xchan_url']; + $r1[$x]['photo'] = $r1[$x]['xchan_photo_s']; $r1[$x]['unseen'] = $r[0]['unseen']; $r1['total'] = $r1['total'] + $r[0]['unseen']; + + unset($r1[$x]['abook_id']); + unset($r1[$x]['xchan_hash']); + unset($r1[$x]['xchan_name']); + unset($r1[$x]['xchan_url']); + unset($r1[$x]['xchan_photo_s']); } else { unset($r1[$x]); } } $result['forums'] = $r1['total']; + unset($r1['total']); + + $result['forums_sub'] = $r1; } $x = json_encode($result); diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index 1be467ba6..a4cf4e706 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -118,12 +118,8 @@ class Notifications { 'severity' => 'secondary', 'label' => t('Forums'), 'title' => t('Forums'), - 'viewall' => [ - //'url' => 'notifications/system', - //'label' => t('View all notices') - ], - 'markall' => [ - //'label' => t('Mark all notices seen') + 'filter' => [ + 'name_label' => t('Filter by name') ] ]; } diff --git a/view/js/main.js b/view/js/main.js index 63ab938f0..7a8ddfe28 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -420,6 +420,14 @@ function notificationsUpdate(cached_data) { // Put the object into storage sessionStorage.setItem('notifications_cache', JSON.stringify(data)); + var fnotifs = []; + if(data.forums) { + $.each(data.forums_sub, function() { + fnotifs.push(this); + }); + handleNotificationsItems('forums', fnotifs); + } + if(data.invalid == 1) { window.location.href=window.location.href; } @@ -495,13 +503,13 @@ function handleNotifications(data) { } function handleNotificationsItems(notifyType, data) { - var notifications_tpl= unescape($("#nav-notifications-template[rel=template]").html()); + var notifications_tpl = ((notifyType == 'forums') ? unescape($("#nav-notifications-forums-template[rel=template]").html()) : unescape($("#nav-notifications-template[rel=template]").html())); var notify_menu = $("#nav-" + notifyType + "-menu"); notify_menu.html(''); $(data).each(function() { - html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top); + html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top,this.unseen); notify_menu.append(html); }); @@ -812,6 +820,14 @@ function updateInit() { if (initialLoad && (sessionStorage.getItem('notifications_cache') !== null)) { var cached_data = JSON.parse(sessionStorage.getItem('notifications_cache')); notificationsUpdate(cached_data); + + var fnotifs = []; + if(cached_data.forums) { + $.each(cached_data.forums_sub, function() { + fnotifs.push(this); + }); + handleNotificationsItems('forums', fnotifs); + } } if(! src) { @@ -1022,6 +1038,7 @@ function loadNotificationItems(notifyType) { } console.log('updating ' + notifyType + ' notifications...'); + $.get(pingExCmd, function(data) { if(data.invalid == 1) { window.location.href=window.location.href; diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 002fa700a..87c97f1f5 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -593,7 +593,8 @@ footer { background-color: $comment_item_colour; } -#nav-notifications-template { +#nav-notifications-template, +#nav-notifications-forums-template { display: none; } @@ -837,6 +838,11 @@ div.jGrowl div.jGrowl-notification { white-space: nowrap; } +.notification.notification-forum { + font-size: 0.9rem; + color: $font_colour; +} + #acl-search::-webkit-input-placeholder { /* non-fontawesome fonts set a fallback for text parts of the placeholder*/ font-family: ForkAwesome, sans-serif, arial, freesans; diff --git a/view/tpl/notifications_widget.tpl b/view/tpl/notifications_widget.tpl index 215fddd08..c71f65b52 100644 --- a/view/tpl/notifications_widget.tpl +++ b/view/tpl/notifications_widget.tpl @@ -127,12 +127,19 @@ {{$no_notifications}}... +