Return count of unread notifications. #474
This commit is contained in:
parent
f5f771c4ed
commit
08b4b25f4e
2 changed files with 8 additions and 6 deletions
|
|
@ -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 = '<div class="m-list-timeline__item">';
|
||||
notif_html += '<span class="m-list-timeline__badge -m-list-timeline__badge--state-success"></span>';
|
||||
notif_html += '<span class="m-list-timeline__text">';
|
||||
//notif_html += '<a href="' + notif.link + '">' + notif.text + '</a>';
|
||||
notif_html += '<a href="">' + notif.text + '</a>'
|
||||
notif_html += '</span>';
|
||||
notif_html += '<span class="m-list-timeline__time">';
|
||||
|
|
@ -61,6 +59,7 @@ class NotificationHandler {
|
|||
window.location.href = notif.link;
|
||||
});
|
||||
});
|
||||
|
||||
notif_index++;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
];
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue