From 170093e88a721d3b2d5ab50d04d86727cb782ed8 Mon Sep 17 00:00:00 2001 From: Matthieu Fesselier Date: Tue, 29 Oct 2019 10:38:24 +0100 Subject: [PATCH] bugfix: fix test unread --- sib-notifications.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sib-notifications.js b/sib-notifications.js index c812ee8..2f72ba3 100644 --- a/sib-notifications.js +++ b/sib-notifications.js @@ -11,8 +11,8 @@ class SIBNotifications extends SIBTemplateElement { constructor() { super() - this.favicon = new Favico({animation:'none'}) - this.title = "" + this.favicon = new Favico({ animation: 'none' }); + this.title = ""; // On read event, mark notification as read window.addEventListener('read', event => { @@ -76,12 +76,12 @@ class SIBNotifications extends SIBTemplateElement { // Add event listener on populate let unreadFilter = this.querySelector('#unread-filter') if (unreadFilter) { - unreadFilter.addEventListener("populate", () => this._updateUnread()) + unreadFilter.addEventListener("populate", () => this._updateUnread()); } let notificationsList = this.querySelector('#notifications-list') if (notificationsList) { - notificationsList.addEventListener("populate", () => this._updateUI()) + notificationsList.addEventListener("populate", () => this._updateUI()); } } @@ -118,13 +118,13 @@ class SIBNotifications extends SIBTemplateElement { _updateUnread() { let unread = this.querySelector('#badge-unread') - if(unread) { + if (unread) { let unreadCount = Number(unread.innerText) - this.favicon.badge(unreadCount) - if(this.title=="") { + if (this.favicon) this.favicon.badge(unreadCount) + if (this.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 } } @@ -132,7 +132,7 @@ class SIBNotifications extends SIBTemplateElement { _updateUI() { const notifications = this.querySelectorAll('#notifications-list sib-display') 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 }); } -- 2.22.2