Added group actions
This commit is contained in:
31
scripts/Actions/Group.ts
Normal file
31
scripts/Actions/Group.ts
Normal file
@ -0,0 +1,31 @@
|
||||
import AnimeNotifier from "scripts/AnimeNotifier"
|
||||
|
||||
// join
|
||||
export async function join(arn: AnimeNotifier, element: HTMLElement) {
|
||||
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) {
|
||||
if(!confirm(`Are you sure you want to leave the group?`)) {
|
||||
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)
|
||||
}
|
||||
}
|
@ -3,17 +3,25 @@ import AnimeNotifier from "../AnimeNotifier"
|
||||
// like
|
||||
export async function like(arn: AnimeNotifier, element: HTMLElement) {
|
||||
arn.statusMessage.showInfo("Liked!", 1000)
|
||||
|
||||
let apiEndpoint = arn.findAPIEndpoint(element)
|
||||
await arn.post(apiEndpoint + "/like", null).catch(err => arn.statusMessage.showError(err))
|
||||
arn.reloadContent()
|
||||
|
||||
try {
|
||||
await arn.post(apiEndpoint + "/like", null)
|
||||
arn.reloadContent()
|
||||
} catch(err) {
|
||||
arn.statusMessage.showError(err)
|
||||
}
|
||||
}
|
||||
|
||||
// unlike
|
||||
export async function unlike(arn: AnimeNotifier, element: HTMLElement) {
|
||||
arn.statusMessage.showInfo("Disliked!", 1000)
|
||||
|
||||
let apiEndpoint = arn.findAPIEndpoint(element)
|
||||
await arn.post(apiEndpoint + "/unlike", null).catch(err => arn.statusMessage.showError(err))
|
||||
arn.reloadContent()
|
||||
|
||||
try {
|
||||
await arn.post(apiEndpoint + "/unlike", null)
|
||||
arn.reloadContent()
|
||||
} catch(err) {
|
||||
arn.statusMessage.showError(err)
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ export * from "./Editor"
|
||||
export * from "./Explore"
|
||||
export * from "./User"
|
||||
export * from "./Forum"
|
||||
export * from "./Group"
|
||||
export * from "./InfiniteScroller"
|
||||
export * from "./Install"
|
||||
export * from "./Like"
|
||||
|
Reference in New Issue
Block a user