27 lines
649 B
TypeScript
Raw Normal View History

2018-04-02 05:34:16 +00:00
import AnimeNotifier from "../AnimeNotifier"
2017-10-17 09:27:15 +00:00
// like
2018-03-20 17:52:35 +00:00
export async function like(arn: AnimeNotifier, element: HTMLElement) {
2018-04-19 14:23:14 +00:00
arn.statusMessage.showInfo("Liked!", 1000)
2018-03-20 17:52:35 +00:00
let apiEndpoint = arn.findAPIEndpoint(element)
2018-11-21 12:29:40 +00:00
try {
2019-04-21 08:39:24 +00:00
await arn.post(apiEndpoint + "/like")
2018-11-21 12:29:40 +00:00
arn.reloadContent()
} catch(err) {
arn.statusMessage.showError(err)
}
2017-10-17 09:27:15 +00:00
}
// unlike
2018-03-20 17:52:35 +00:00
export async function unlike(arn: AnimeNotifier, element: HTMLElement) {
2018-04-19 14:23:14 +00:00
arn.statusMessage.showInfo("Disliked!", 1000)
2018-03-20 17:52:35 +00:00
let apiEndpoint = arn.findAPIEndpoint(element)
2018-11-21 12:29:40 +00:00
try {
2019-04-21 08:39:24 +00:00
await arn.post(apiEndpoint + "/unlike")
2018-11-21 12:29:40 +00:00
arn.reloadContent()
} catch(err) {
arn.statusMessage.showError(err)
}
2017-10-17 09:27:15 +00:00
}