35 lines
823 B
TypeScript
Raw Normal View History

2018-11-21 12:29:40 +00:00
import AnimeNotifier from "scripts/AnimeNotifier"
// join
export async function join(arn: AnimeNotifier, element: HTMLElement) {
2018-11-22 02:13:39 +00:00
if(!confirm(`Are you sure you want to join this group?`)) {
return
}
2018-11-21 12:29:40 +00:00
let apiEndpoint = arn.findAPIEndpoint(element)
try {
2018-11-22 04:36:04 +00:00
await arn.post(`${apiEndpoint}/join`, null)
2018-11-21 12:29:40 +00:00
arn.reloadContent()
2018-11-22 04:36:04 +00:00
arn.statusMessage.showInfo("Joined group!", 1000)
2018-11-21 12:29:40 +00:00
} catch(err) {
arn.statusMessage.showError(err)
}
}
// leave
export async function leave(arn: AnimeNotifier, element: HTMLElement) {
2018-11-22 02:13:39 +00:00
if(!confirm(`Are you sure you want to leave this group?`)) {
2018-11-21 12:29:40 +00:00
return
}
let apiEndpoint = arn.findAPIEndpoint(element)
try {
2018-11-22 04:36:04 +00:00
await arn.post(`${apiEndpoint}/leave`, null)
2018-11-21 12:29:40 +00:00
arn.reloadContent()
2018-11-22 04:36:04 +00:00
arn.statusMessage.showInfo("Left group!", 1000)
2018-11-21 12:29:40 +00:00
} catch(err) {
arn.statusMessage.showError(err)
}
}