Added notification count badge

This commit is contained in:
2018-02-28 16:26:49 +01:00
parent 6f01b654d3
commit fceec3f193
8 changed files with 80 additions and 3 deletions

View File

@ -0,0 +1,31 @@
export class NotificationManager {
unseen: number
async update() {
let response = await fetch("/api/count/notifications/unseen", {
credentials: "same-origin"
})
let body = await response.text()
this.unseen = parseInt(body)
this.unseen = 2
this.render()
}
render() {
console.log("notification count", this.unseen)
let notificationIcon = document.getElementById("notification-icon")
let notificationCount = document.getElementById("notification-count")
notificationCount.innerText = this.unseen.toString()
if(this.unseen === 0) {
notificationCount.classList.add("hidden")
notificationIcon.classList.remove("hidden")
} else {
notificationIcon.classList.add("hidden")
notificationCount.classList.remove("hidden")
}
}
}