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
|
|
|
arn.statusMessage.showInfo("Joined group!", 1000)
|
|
|
|
let apiEndpoint = arn.findAPIEndpoint(element)
|
|
|
|
|
|
|
|
try {
|
|
|
|
await arn.post(apiEndpoint + "/join", null)
|
|
|
|
arn.reloadContent()
|
|
|
|
} 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
|
|
|
|
}
|
|
|
|
|
|
|
|
arn.statusMessage.showInfo("Left group!", 1000)
|
|
|
|
let apiEndpoint = arn.findAPIEndpoint(element)
|
|
|
|
|
|
|
|
try {
|
|
|
|
await arn.post(apiEndpoint + "/leave", null)
|
|
|
|
arn.reloadContent()
|
|
|
|
} catch(err) {
|
|
|
|
arn.statusMessage.showError(err)
|
|
|
|
}
|
|
|
|
}
|