Add status message when liking stuff

This commit is contained in:
Eduard Urbach 2018-03-20 18:52:35 +01:00
parent 2dae63412f
commit 30d9b9cdbc

View File

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