Refactor actions

This commit is contained in:
2017-10-17 11:27:15 +02:00
parent 56815fcb22
commit d65f3fd7bb
16 changed files with 450 additions and 429 deletions

19
scripts/Actions/Like.ts Normal file
View File

@ -0,0 +1,19 @@
import { AnimeNotifier } from "../AnimeNotifier"
// like
export function like(arn: AnimeNotifier, element: HTMLElement) {
let apiEndpoint = arn.findAPIEndpoint(element)
arn.post(apiEndpoint + "/like", null)
.then(() => arn.reloadContent())
.catch(err => arn.statusMessage.showError(err))
}
// unlike
export function unlike(arn: AnimeNotifier, element: HTMLElement) {
let apiEndpoint = arn.findAPIEndpoint(element)
arn.post(apiEndpoint + "/unlike", null)
.then(() => arn.reloadContent())
.catch(err => arn.statusMessage.showError(err))
}