26 lines
624 B
TypeScript
Raw Normal View History

2018-04-02 07:34:16 +02:00
import AnimeNotifier from "../AnimeNotifier"
2017-10-17 11:27:15 +02:00
// Publish
2019-04-22 15:02:51 +09:00
export async function publish(arn: AnimeNotifier, button: HTMLButtonElement) {
2019-11-17 18:25:14 +09:00
const endpoint = arn.findAPIEndpoint(button)
2017-10-17 11:27:15 +02:00
2019-04-22 15:02:51 +09:00
try {
await arn.post(endpoint + "/publish")
await arn.app.load(arn.app.currentPath.replace("/edit", ""))
} catch(err) {
arn.statusMessage.showError(err)
}
2017-10-17 11:27:15 +02:00
}
// Unpublish
2019-04-22 15:02:51 +09:00
export async function unpublish(arn: AnimeNotifier, button: HTMLButtonElement) {
2019-11-17 18:25:14 +09:00
const endpoint = arn.findAPIEndpoint(button)
2017-10-17 11:27:15 +02:00
2019-04-22 15:02:51 +09:00
try {
await arn.post(endpoint + "/unpublish")
await arn.reloadContent()
} catch(err) {
arn.statusMessage.showError(err)
}
2019-11-17 18:44:30 +09:00
}