Commit 170093e8 authored by Matthieu Fesselier's avatar Matthieu Fesselier

bugfix: fix test unread

parent 9c2d33f6
Pipeline #6218 passed with stage
in 1 minute and 34 seconds
...@@ -11,8 +11,8 @@ class SIBNotifications extends SIBTemplateElement { ...@@ -11,8 +11,8 @@ class SIBNotifications extends SIBTemplateElement {
constructor() { constructor() {
super() super()
this.favicon = new Favico({animation:'none'}) this.favicon = new Favico({ animation: 'none' });
this.title = "" this.title = "";
// On read event, mark notification as read // On read event, mark notification as read
window.addEventListener('read', event => { window.addEventListener('read', event => {
...@@ -76,12 +76,12 @@ class SIBNotifications extends SIBTemplateElement { ...@@ -76,12 +76,12 @@ class SIBNotifications extends SIBTemplateElement {
// Add event listener on populate // Add event listener on populate
let unreadFilter = this.querySelector('#unread-filter') let unreadFilter = this.querySelector('#unread-filter')
if (unreadFilter) { if (unreadFilter) {
unreadFilter.addEventListener("populate", () => this._updateUnread()) unreadFilter.addEventListener("populate", () => this._updateUnread());
} }
let notificationsList = this.querySelector('#notifications-list') let notificationsList = this.querySelector('#notifications-list')
if (notificationsList) { if (notificationsList) {
notificationsList.addEventListener("populate", () => this._updateUI()) notificationsList.addEventListener("populate", () => this._updateUI());
} }
} }
...@@ -118,13 +118,13 @@ class SIBNotifications extends SIBTemplateElement { ...@@ -118,13 +118,13 @@ class SIBNotifications extends SIBTemplateElement {
_updateUnread() { _updateUnread() {
let unread = this.querySelector('#badge-unread') let unread = this.querySelector('#badge-unread')
if(unread) { if (unread) {
let unreadCount = Number(unread.innerText) let unreadCount = Number(unread.innerText)
this.favicon.badge(unreadCount) if (this.favicon) this.favicon.badge(unreadCount)
if(this.title=="") { if (this.title == "") {
this.title = document.title; this.title = document.title;
} }
if(unreadCount > 0) document.title = "(" + unreadCount + ") " + this.title if (unreadCount > 0) document.title = "(" + unreadCount + ") " + this.title
else document.title = this.title else document.title = this.title
} }
} }
...@@ -132,7 +132,7 @@ class SIBNotifications extends SIBTemplateElement { ...@@ -132,7 +132,7 @@ class SIBNotifications extends SIBTemplateElement {
_updateUI() { _updateUI() {
const notifications = this.querySelectorAll('#notifications-list sib-display') const notifications = this.querySelectorAll('#notifications-list sib-display')
notifications.forEach(async notif => { notifications.forEach(async notif => {
if (!(await notif.component.resource.unread == 'true')) notif.setAttribute('data-read', 'true') // opacity unread if (!((await notif.component.resource.unread).toString() == 'true')) notif.setAttribute('data-read', 'true') // opacity unread
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment