36 lines
816 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
}
2019-11-17 09:25:14 +00:00
const apiEndpoint = arn.findAPIEndpoint(element)
2018-11-21 12:29:40 +00:00
try {
2019-04-21 08:39:24 +00:00
await arn.post(`${apiEndpoint}/join`)
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
}
2019-11-17 09:25:14 +00:00
const apiEndpoint = arn.findAPIEndpoint(element)
2018-11-21 12:29:40 +00:00
try {
2019-04-21 08:39:24 +00:00
await arn.post(`${apiEndpoint}/leave`)
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)
}
2019-11-17 09:44:30 +00:00
}