Added anime list deletion

This commit is contained in:
2019-08-29 14:08:32 +09:00
parent 1d6cdd3c9f
commit ede2c5dc75
6 changed files with 82 additions and 2 deletions

View File

@ -33,7 +33,6 @@ export async function removeAnimeFromCollection(arn: AnimeNotifier, button: HTML
}
button.textContent = "Removing..."
let {animeId, nick} = button.dataset
if(!animeId || !nick) {
@ -50,4 +49,27 @@ export async function removeAnimeFromCollection(arn: AnimeNotifier, button: HTML
} catch(err) {
arn.statusMessage.showError(err)
}
}
}
// Delete anime list
export async function deleteAnimeList(arn: AnimeNotifier, button: HTMLElement) {
if(!confirm("Last confirmation: Are you sure you want to delete your entire anime list?")) {
return
}
button.textContent = "Deleting..."
let {returnPath} = button.dataset
if(!returnPath) {
console.error("Button without data-return-path:", button)
return
}
try {
await arn.post("/api/delete/animelist")
await arn.app.load(returnPath)
arn.statusMessage.showInfo("Your anime list has been deleted.")
} catch(err) {
arn.statusMessage.showError(err)
}
}