From e4142a9762e2be741cbe9b44a84ad4077c4d0204 Mon Sep 17 00:00:00 2001 From: Fulmine Date: Sat, 19 Mar 2022 12:42:28 +0100 Subject: [PATCH] Allow for editing groups for now --- src/lib/group/Body.svelte | 5 +++-- src/pages/Member.svelte | 22 +++++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/lib/group/Body.svelte b/src/lib/group/Body.svelte index 25efd23a..becdabc7 100644 --- a/src/lib/group/Body.svelte +++ b/src/lib/group/Body.svelte @@ -103,8 +103,9 @@ {#if (group.banner && ((settings && settings.appearance.banner_bottom) || !settings))} your system banner {/if} -{#if !isPublic && isMainDash} - +{#if !isPublic} + +{#if isMainDash}{/if} {/if} {:else if editMode} diff --git a/src/pages/Member.svelte b/src/pages/Member.svelte index 54609f9b..4dd0b4fd 100644 --- a/src/pages/Member.svelte +++ b/src/pages/Member.svelte @@ -21,6 +21,7 @@ let member: Member; let groups: Group[] = []; let systemGroups: Group[] = []; + let systemMembers: Member[] = []; let isMainDash = false; let isDeleted = false; @@ -60,13 +61,19 @@ async function fetchGroups() { try { - groups = await api().members($params.id).groups().get({auth: !isPublic}); + groups = await api().members($params.id).groups().get({auth: !isPublic, query: { with_members: !isPublic } }); if (!isPublic) { await new Promise(resolve => setTimeout(resolve, 1000)); systemGroups = await api().systems("@me").groups.get({ auth: true, query: { with_members: true } }); } groupErr = ""; groupLoading = false; + // we can't use with_members from a group list from a member endpoint yet, but I'm leaving this in in case we do + // (this is needed for editing a group member list from the member page) + /* if (!isPublic) { + await new Promise(resolve => setTimeout(resolve, 1000)); + systemMembers = await api().systems("@me").members.get({auth: true}); + } */ } catch (error) { console.log(error); groupErr = error.message; @@ -83,7 +90,16 @@ function updateDelete() { isDeleted = true; } + + function updateGroupList(event: any) { + groups = groups.map(group => group.id !== event.detail.id ? group : event.detail); + systemGroups = systemGroups.map(group => group.id !== event.detail.id ? group : event.detail); + } + function deleteGroupFromList(event: any) { + groups = groups.filter(group => group.id !== event.detail); + systemGroups = systemGroups.filter(group => group.id !== event.detail); + } {#if settings && settings.appearance.color_background} @@ -139,14 +155,14 @@ - + {:else} - + {/if} {/each}