@JeuriMorel
Posted
Clicking on a notification makes the counter go up indefinitely but I'm pretty sure that the counter is supposed to represent the number of unread notifications. So it should start with how many of the notifications are in the unread state and decrease by one whenever those notifications are marked as read.
@iamcelestino
Posted
Thanks a lot.
I made all the change you suggested. but I the didn't get success, stopping the counter.
can you give an Idea?
how did you see the way I wrote my JS code is that the good way, is the room for improvements apart from the one you mentioned?
@JeuriMorel
@JeuriMorel
Posted
@iamcelestino
I took a look at your JS and it looks like you're always decreasing count every time the notification is clicked. I would add an if
statement to run the code only if the notification is unread. I would rearrange your event listener function to look more like this:
notifications.forEach(notification => {
notification.addEventListener("click", () => {
const marker = notification.childNodes[3].childNodes[1].firstChild.nextSibling.childNodes[2];
if (marker.classList.contains("marker")) {
count--;
countReadNotification(count);
notification.classList.add("change__color");
marker.classList.remove("marker");
}
})
});
@iamcelestino
Posted
THANKS A LOT. @JeuriMorel
@JeuriMorel
Posted
@iamcelestino You're welcome. :)