PHRAS-3442_optimize-list-notifications_4.1-bis

WIP
mark notif as read
fix test
This commit is contained in:
jygaulier
2021-06-17 17:13:35 +02:00
parent f8cfd08f4f
commit 47c0e4b1cc
10 changed files with 160 additions and 143 deletions

View File

@@ -194,6 +194,10 @@ const notifyLayout = (services) => {
// add pre-formatted notif
date_cont.append(notification.html);
$('.notification_' + notification.id + '_unread', $notifications).tooltip().click(
function () {
mark_read(notification.id);
});
}
// handle "show more" button
@@ -216,26 +220,21 @@ const notifyLayout = (services) => {
}
});
};
/* remove in favor of existing /session/ route
const read_notifications = () => {
var notifications = [];
$('#notification_box .unread').each(function () {
notifications.push($(this).attr('id').split('_').pop());
});
const mark_read = (notification_id) => {
$.ajax({
type: 'POST',
url: '/user/notifications/read/',
type: 'PATCH',
url: '/user/notifications/' + notification_id + '/',
data: {
notifications: notifications.join('_')
'read': 1
},
success: function (data) {
$('.notification_trigger .counter').css('visibility', 'hidden').empty();
$('.notification_' + notification_id + '_unread', $notifications).hide();
$('.notification_' + notification_id + '_read', $notifications).show();
}
});
};
/*
const clear_notifications = () => {
var unread = $('#notification_box .unread');