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