2018-11-22 13:36:04 +09:00

35 lines
823 B
TypeScript

import AnimeNotifier from "scripts/AnimeNotifier"
// join
export async function join(arn: AnimeNotifier, element: HTMLElement) {
if(!confirm(`Are you sure you want to join this group?`)) {
return
}
let apiEndpoint = arn.findAPIEndpoint(element)
try {
await arn.post(`${apiEndpoint}/join`, null)
arn.reloadContent()
arn.statusMessage.showInfo("Joined group!", 1000)
} catch(err) {
arn.statusMessage.showError(err)
}
}
// leave
export async function leave(arn: AnimeNotifier, element: HTMLElement) {
if(!confirm(`Are you sure you want to leave this group?`)) {
return
}
let apiEndpoint = arn.findAPIEndpoint(element)
try {
await arn.post(`${apiEndpoint}/leave`, null)
arn.reloadContent()
arn.statusMessage.showInfo("Left group!", 1000)
} catch(err) {
arn.statusMessage.showError(err)
}
}