Replace polling with server sent events

This commit is contained in:
2018-11-07 16:49:49 +09:00
parent e56782d5a3
commit 79da84956e
8 changed files with 108 additions and 117 deletions

View File

@ -31,18 +31,6 @@ export async function markNotificationsAsSeen(arn: AnimeNotifier) {
credentials: "same-origin"
})
// Update notification counter
if("serviceWorker" in navigator) {
// 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"
})
} else {
// If there is no service worker, update the counter on this tab
arn.notificationManager.update()
}
// Update notifications
arn.reloadContent()
}