Mark all notifications as seen syncs all tabs
This commit is contained in:
@ -30,7 +30,16 @@ export async function markNotificationsAsSeen(arn: AnimeNotifier) {
|
||||
})
|
||||
|
||||
// Update notification counter
|
||||
arn.notificationManager.update()
|
||||
if(!("serviceWorker" in navigator)) {
|
||||
// If there is no service worker, update the counter on this tab
|
||||
arn.notificationManager.update()
|
||||
} else {
|
||||
// If we have service worker support, broadcast the "notifications marked as seen" message to all open tabs
|
||||
arn.serviceWorkerManager.postMessage({
|
||||
type: "broadcast",
|
||||
realType: "notifications marked as seen"
|
||||
})
|
||||
}
|
||||
|
||||
// Update notifications
|
||||
arn.reloadContent()
|
||||
|
@ -11,12 +11,10 @@ export class ServiceWorkerManager {
|
||||
|
||||
register() {
|
||||
if(!("serviceWorker" in navigator)) {
|
||||
console.log("service worker not supported, skipping registration")
|
||||
console.warn("service worker not supported, skipping registration")
|
||||
return
|
||||
}
|
||||
|
||||
console.log("register service worker")
|
||||
|
||||
navigator.serviceWorker.register(this.uri).then(registration => {
|
||||
// registration.update()
|
||||
})
|
||||
@ -74,6 +72,7 @@ export class ServiceWorkerManager {
|
||||
|
||||
switch(message.type) {
|
||||
case "new notification":
|
||||
case "notifications marked as seen":
|
||||
this.arn.notificationManager.update()
|
||||
break
|
||||
|
||||
|
Reference in New Issue
Block a user