Push notifications

This commit is contained in:
2017-07-14 23:50:34 +02:00
parent 2e504548c4
commit 92a540e024
9 changed files with 276 additions and 18 deletions

View File

@ -214,6 +214,23 @@ export function search(arn: AnimeNotifier, search: HTMLInputElement, e: Keyboard
arn.diff("/search/" + term)
}
// Enable notifications
export function enableNotifications(arn: AnimeNotifier, button: HTMLElement) {
arn.pushManager.subscribe(arn.user.dataset.id)
}
// Disable notifications
export function disableNotifications(arn: AnimeNotifier, button: HTMLElement) {
arn.pushManager.unsubscribe(arn.user.dataset.id)
}
// Test notification
export function testNotification(arn: AnimeNotifier) {
fetch("/api/test/notification", {
credentials: "same-origin"
})
}
// Add anime to collection
export function addAnimeToCollection(arn: AnimeNotifier, button: HTMLElement) {
button.innerText = "Adding..."