Added deletion to Kitsu imports

This commit is contained in:
2018-04-17 12:27:54 +02:00
parent 9eae7ebce5
commit 8cb44131cf
7 changed files with 73 additions and 6 deletions

@ -23,6 +23,10 @@ export function newAnimeDiffIgnore(arn: AnimeNotifier, button: HTMLButtonElement
// Import Kitsu anime
export async function importKitsuAnime(arn: AnimeNotifier, button: HTMLButtonElement) {
if(!confirm("Are you sure you want to import this anime?")) {
return
}
let newTab = window.open()
let animeId = button.dataset.id
let response = await fetch(`/api/import/kitsu/anime/${animeId}`, {
@ -38,6 +42,17 @@ export async function importKitsuAnime(arn: AnimeNotifier, button: HTMLButtonEle
}
}
// Delete Kitsu anime
export async function deleteKitsuAnime(arn: AnimeNotifier, button: HTMLButtonElement) {
if(!confirm("Are you sure you want to delete this anime?")) {
return
}
let animeId = button.dataset.id
await arn.post(`/api/delete/kitsu/anime/${animeId}`)
arn.reloadContent()
}
// Multi-search anime
export async function multiSearchAnime(arn: AnimeNotifier, textarea: HTMLTextAreaElement) {
let results = document.getElementById("multi-search-anime") as HTMLDivElement

@ -804,12 +804,12 @@ export default class AnimeNotifier {
return Diff.innerHTML(element, html)
}
post(url: string, body: any) {
post(url: string, body?: any) {
if(this.isLoading) {
return Promise.resolve(null)
}
if(typeof body !== "string") {
if(body !== undefined && typeof body !== "string") {
body = JSON.stringify(body)
}