37 lines
912 B
TypeScript
Raw Normal View History

2018-04-02 05:34:16 +00:00
import AnimeNotifier from "../AnimeNotifier"
2018-03-09 13:48:00 +00:00
// newAnimeDiffIgnore
export function newAnimeDiffIgnore(arn: AnimeNotifier, button: HTMLButtonElement) {
if(!confirm("Are you sure you want to permanently ignore this difference?")) {
return
}
let id = button.dataset.id
let hash = button.dataset.hash
arn.post(`/api/new/ignoreanimedifference`, {
id,
hash
})
.then(() => {
arn.reloadContent()
})
.catch(err => arn.statusMessage.showError(err))
2018-03-10 09:15:05 +00:00
}
2018-03-18 20:41:13 +00:00
// Import Kitsu anime
export async function importKitsuAnime(arn: AnimeNotifier, button: HTMLButtonElement) {
2018-03-18 21:44:03 +00:00
let newTab = window.open()
let animeId = button.dataset.id
let response = await fetch(`/api/import/kitsu/anime/${animeId}`, {
2018-03-18 20:41:13 +00:00
method: "POST",
credentials: "same-origin"
})
if(response.ok) {
newTab.location.href = `/kitsu/anime/${animeId}`
2018-03-18 20:41:13 +00:00
arn.reloadContent()
} else {
arn.statusMessage.showError(await response.text())
}
2018-03-09 13:48:00 +00:00
}