Refactor actions
This commit is contained in:
19
scripts/Actions/Publish.ts
Normal file
19
scripts/Actions/Publish.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { AnimeNotifier } from "../AnimeNotifier"
|
||||
|
||||
// Publish
|
||||
export function publish(arn: AnimeNotifier, button: HTMLButtonElement) {
|
||||
let endpoint = arn.findAPIEndpoint(button)
|
||||
|
||||
arn.post(endpoint + "/publish", "")
|
||||
.then(() => arn.app.load(arn.app.currentPath.replace("/edit", "")))
|
||||
.catch(err => arn.statusMessage.showError(err))
|
||||
}
|
||||
|
||||
// Unpublish
|
||||
export function unpublish(arn: AnimeNotifier, button: HTMLButtonElement) {
|
||||
let endpoint = arn.findAPIEndpoint(button)
|
||||
|
||||
arn.post(endpoint + "/unpublish", "")
|
||||
.then(() => arn.reloadContent())
|
||||
.catch(err => arn.statusMessage.showError(err))
|
||||
}
|
Reference in New Issue
Block a user