Add null checks and make use of insertAdjacentHTML

This commit is contained in:
2019-04-19 23:34:49 +09:00
parent d16197340d
commit 6ec4017638
3 changed files with 36 additions and 16 deletions

View File

@ -2,6 +2,10 @@ import AnimeNotifier from "../AnimeNotifier"
// Enable notifications
export async function enableNotifications(arn: AnimeNotifier, button: HTMLElement) {
if(!arn.user || !arn.user.dataset.id) {
return
}
arn.statusMessage.showInfo("Enabling instant notifications...")
await arn.pushManager.subscribe(arn.user.dataset.id)
arn.updatePushUI()
@ -10,6 +14,10 @@ export async function enableNotifications(arn: AnimeNotifier, button: HTMLElemen
// Disable notifications
export async function disableNotifications(arn: AnimeNotifier, button: HTMLElement) {
if(!arn.user || !arn.user.dataset.id) {
return
}
arn.statusMessage.showInfo("Disabling instant notifications...")
await arn.pushManager.unsubscribe(arn.user.dataset.id)
arn.updatePushUI()