Cleanup
This commit is contained in:
@ -1,5 +1,14 @@
|
||||
import { Diff } from "./Diff"
|
||||
|
||||
export class NotificationManager {
|
||||
unseen: number
|
||||
icon: HTMLElement
|
||||
counter: HTMLElement
|
||||
|
||||
constructor() {
|
||||
this.icon = document.getElementById("notification-icon")
|
||||
this.counter = document.getElementById("notification-count")
|
||||
}
|
||||
|
||||
async update() {
|
||||
let response = await fetch("/api/count/notifications/unseen", {
|
||||
@ -17,17 +26,16 @@ export class NotificationManager {
|
||||
}
|
||||
|
||||
render() {
|
||||
let notificationIcon = document.getElementById("notification-icon")
|
||||
let notificationCount = document.getElementById("notification-count")
|
||||
Diff.mutations.queue(() => {
|
||||
this.counter.innerText = this.unseen.toString()
|
||||
|
||||
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")
|
||||
}
|
||||
if(this.unseen === 0) {
|
||||
this.counter.classList.add("hidden")
|
||||
this.icon.classList.remove("hidden")
|
||||
} else {
|
||||
this.icon.classList.add("hidden")
|
||||
this.counter.classList.remove("hidden")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user