Browse Source

js: notifs: Se una notifica viene letta aggiornane la classe.

* web/mustard/js/notifs.js.php (markread): Aggiunto caso in cui la
  funzione viene chiamata su un elemento della pagina di gestione
  delle notifiche.
paul 4 years ago
parent
commit
6bdb2c865b
1 changed files with 9 additions and 1 deletions
  1. 9 1
      web/mustard/js/notifs.js.php

+ 9 - 1
web/mustard/js/notifs.js.php

@@ -19,13 +19,21 @@ function markread(notif) {
 	xhr.responseType='json';
 	xhr.send();
 	xhr.onload=function() {
-		notif.className='notifseen';
 		let jarr=xhr.response;
 		if (jarr['hmunseen']==0) {
 			notifimgon='imgs/bell_on.svg';
 			notifimgoff='imgs/bell_off.svg';
 			bell.src=notifimgon;
 		}
+
+		if (notif.classList.contains("notifunseen")){
+		    // Notifica nella navbar
+            notif.className='notifseen';
+		} else if (notif.classList.contains("unseen")) {
+		    // Notifica nella pagina di gestione notifiche
+            notif.classList.remove("unseen");
+            notif.classList.add("seen");
+        }
 	};
 	xhr.onerror=function() {
 		alert('La richiesta è fallita.');