36 lines
816 B
TypeScript
Raw Normal View History

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