diff --git a/images/elements/no-group-image.svg b/images/elements/no-group-image.svg
index c79bfd50..553f7c33 100644
--- a/images/elements/no-group-image.svg
+++ b/images/elements/no-group-image.svg
@@ -1 +1 @@
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/pages/group/members.pixy b/pages/group/members.pixy
index 58601a0f..f22b602c 100644
--- a/pages/group/members.pixy
+++ b/pages/group/members.pixy
@@ -6,7 +6,12 @@ component GroupMembers(group *arn.Group, member *arn.GroupMember, user *arn.User
each member in group.Members
Avatar(member.User())
- .buttons
- button.mountable
- Icon("user-plus")
- span= fmt.Sprintf(`Join "%s"`, group.Name)
\ No newline at end of file
+ .buttons(data-api="/api" + group.Link())
+ if member == nil
+ button.mountable.action(data-action="join", data-trigger="click")
+ Icon("user-plus")
+ span= fmt.Sprintf(`Join "%s"`, group.Name)
+ else
+ button.mountable.action(data-action="leave", data-trigger="click")
+ Icon("user-times")
+ span= fmt.Sprintf(`Leave "%s"`, group.Name)
\ No newline at end of file
diff --git a/scripts/Actions/Group.ts b/scripts/Actions/Group.ts
new file mode 100644
index 00000000..71dab1b9
--- /dev/null
+++ b/scripts/Actions/Group.ts
@@ -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)
+ }
+}
\ No newline at end of file
diff --git a/scripts/Actions/Like.ts b/scripts/Actions/Like.ts
index 9375da44..c6a7383b 100644
--- a/scripts/Actions/Like.ts
+++ b/scripts/Actions/Like.ts
@@ -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)
+ }
}
\ No newline at end of file
diff --git a/scripts/Actions/index.ts b/scripts/Actions/index.ts
index 6dd6d70a..f3e221f5 100644
--- a/scripts/Actions/index.ts
+++ b/scripts/Actions/index.ts
@@ -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"