From 5bdb25866c844579e3335429d60330135f3d6a50 Mon Sep 17 00:00:00 2001
From: Sam
Date: Sun, 2 Apr 2023 23:08:44 +0200
Subject: [PATCH] feat: add hidden member list
---
backend/routes/member/get_members.go | 11 +++++--
frontend/src/routes/@[username]/+page.svelte | 5 ++-
frontend/src/routes/settings/+layout.svelte | 12 +++++++
frontend/src/routes/settings/+layout.ts | 3 ++
.../src/routes/settings/members/+page.svelte | 31 +++++++++++++++++++
5 files changed, 58 insertions(+), 4 deletions(-)
create mode 100644 frontend/src/routes/settings/members/+page.svelte
diff --git a/backend/routes/member/get_members.go b/backend/routes/member/get_members.go
index 7883744..34c0b35 100644
--- a/backend/routes/member/get_members.go
+++ b/backend/routes/member/get_members.go
@@ -19,9 +19,10 @@ type memberListResponse struct {
Links []string `json:"links"`
Names []db.FieldEntry `json:"names"`
Pronouns []db.PronounEntry `json:"pronouns"`
+ Unlisted bool `json:"unlisted"`
}
-func membersToMemberList(ms []db.Member) []memberListResponse {
+func membersToMemberList(ms []db.Member, isSelf bool) []memberListResponse {
resps := make([]memberListResponse, len(ms))
for i := range ms {
resps[i] = memberListResponse{
@@ -33,6 +34,10 @@ func membersToMemberList(ms []db.Member) []memberListResponse {
Names: db.NotNull(ms[i].Names),
Pronouns: db.NotNull(ms[i].Pronouns),
}
+
+ if isSelf {
+ resps[i].Unlisted = ms[i].Unlisted
+ }
}
return resps
@@ -66,7 +71,7 @@ func (s *Server) getUserMembers(w http.ResponseWriter, r *http.Request) error {
return err
}
- render.JSON(w, r, membersToMemberList(ms))
+ render.JSON(w, r, membersToMemberList(ms, isSelf))
return nil
}
@@ -79,6 +84,6 @@ func (s *Server) getMeMembers(w http.ResponseWriter, r *http.Request) error {
return err
}
- render.JSON(w, r, membersToMemberList(ms))
+ render.JSON(w, r, membersToMemberList(ms, true))
return nil
}
diff --git a/frontend/src/routes/@[username]/+page.svelte b/frontend/src/routes/@[username]/+page.svelte
index f57cb27..29686c6 100644
--- a/frontend/src/routes/@[username]/+page.svelte
+++ b/frontend/src/routes/@[username]/+page.svelte
@@ -30,7 +30,7 @@
import { apiFetchClient } from "$lib/api/fetch";
import ErrorAlert from "$lib/components/ErrorAlert.svelte";
import { goto } from "$app/navigation";
- import {renderMarkdown} from "$lib/utils"
+ import { renderMarkdown } from "$lib/utils";
import ReportButton from "./ReportButton.svelte";
import ProfileLink from "./ProfileLink.svelte";
import { memberNameRegex } from "$lib/api/regex";
@@ -212,6 +212,9 @@
You don't have any members yet.
Members are sub-profiles that can have their own avatar, names, pronouns, and preferred terms.
+
+ If you were expecting to see members here, check your
+ list of hidden members.
(only you can see this)
diff --git a/frontend/src/routes/settings/+layout.svelte b/frontend/src/routes/settings/+layout.svelte
index 416f691..6921b22 100644
--- a/frontend/src/routes/settings/+layout.svelte
+++ b/frontend/src/routes/settings/+layout.svelte
@@ -31,6 +31,9 @@
let unreadWarnings: number;
$: unreadWarnings = data.warnings.filter((w) => !w.read).length;
+
+ let hasHiddenMembers: boolean;
+ $: hasHiddenMembers = data.user.list_private || data.members.some((m) => m.unlisted);
@@ -53,6 +56,15 @@
>
Authentication
+
+
+ Hidden members
+
+
{#if data.invitesEnabled}
{
try {
const user = await apiFetchClient("/users/@me");
+ const members = await apiFetchClient("/users/@me/members");
const warnings = await apiFetchClient("/auth/warnings?all=true");
let invites: Invite[] = [];
@@ -31,6 +33,7 @@ export const load = (async ({ parent }) => {
return {
...data,
user,
+ members,
invites,
invitesEnabled,
warnings,
diff --git a/frontend/src/routes/settings/members/+page.svelte b/frontend/src/routes/settings/members/+page.svelte
new file mode 100644
index 0000000..399b219
--- /dev/null
+++ b/frontend/src/routes/settings/members/+page.svelte
@@ -0,0 +1,31 @@
+
+
+Hidden members ({members.length})
+
+{#if data.user.list_private}
+
+ Note that your member list is hidden, so all of your members are shown here.
+
+{/if}
+
+{#if members.length > 0}
+
+ {#each members as member}
+
+ {member.display_name ?? member.name}
+ ({member.name})
+
+ {/each}
+
+{:else}
+ You have no unlisted members!
+{/if}