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