diff --git a/public/assets/js/notification.js b/public/assets/js/notification.js
index 1758ade3..9a4b169c 100644
--- a/public/assets/js/notification.js
+++ b/public/assets/js/notification.js
@@ -23,9 +23,8 @@ class NotificationHandler {
var data = JSON.parse(xhr.responseText);
var notifs = data.notifications;
- // update notification count
- // TODO: notification count is total count or total unread count?
- var count_html = data.count;
+ // update notification unread count
+ var count_html = data.unread_count;
document.getElementById('notif-count').innerHTML = count_html;
// do we have any notifications?
@@ -41,7 +40,6 @@ class NotificationHandler {
var notif_html = '
';
notif_html += '
';
notif_html += '
';
- //notif_html += '' + notif.text + '';
notif_html += '' + notif.text + ''
notif_html += '';
notif_html += '
';
@@ -61,6 +59,7 @@ class NotificationHandler {
window.location.href = notif.link;
});
});
+
notif_index++;
});
}
diff --git a/src/Controller/NotificationController.php b/src/Controller/NotificationController.php
index 6414ce55..64150c51 100644
--- a/src/Controller/NotificationController.php
+++ b/src/Controller/NotificationController.php
@@ -56,10 +56,12 @@ class NotificationController extends AbstractController
$notifs = $em->getRepository(Notification::class)->findBy(['user_id' => 0]);
$notif_data = [];
- // TODO: count how many notifs are unread and return the count
-
+ $unread_count = 0;
foreach ($notifs as $notif)
{
+ if (!($notif->isRead()))
+ $unread_count++;
+
$notif_data[] = [
'id' => $notif->getID(),
'type' => 'jo_new',
@@ -74,6 +76,7 @@ class NotificationController extends AbstractController
$sample_data = [
'count' => count($notif_data),
+ 'unread_count' => $unread_count,
'notifications' => $notif_data,
];