Commit 3afcde92 authored by Jean-Baptiste Pasquier's avatar Jean-Baptiste Pasquier

update: Add notification number to app title

parent a96f829e
Pipeline #5214 passed with stage
in 1 minute and 27 seconds
...@@ -13,6 +13,8 @@ class SIBNotifications extends SIBTemplateElement { ...@@ -13,6 +13,8 @@ class SIBNotifications extends SIBTemplateElement {
this.favicon = new Favico({animation:'none'}) this.favicon = new Favico({animation:'none'})
this.title = ""
// On read event, mark notification as read // On read event, mark notification as read
window.addEventListener('read', event => { window.addEventListener('read', event => {
if(event.detail && event.detail.resource && event.detail.resource['@id']) { if(event.detail && event.detail.resource && event.detail.resource['@id']) {
...@@ -116,7 +118,15 @@ class SIBNotifications extends SIBTemplateElement { ...@@ -116,7 +118,15 @@ class SIBNotifications extends SIBTemplateElement {
_updateUnread() { _updateUnread() {
let unread = this.querySelector('#badge-unread') let unread = this.querySelector('#badge-unread')
if(unread) this.favicon.badge(Number(unread.innerText)) if(unread) {
let unreadCount = Number(unread.innerText)
this.favicon.badge(unreadCount)
if(this.title=="") {
this.title = document.title;
}
if(unreadCount > 0) document.title = "(" + unreadCount + ") " + this.title
else document.title = this.title
}
} }
_updateUI() { _updateUI() {
......
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