feat: fetch full members list when navigating to own user page

This commit is contained in:
Sam 2023-05-08 23:07:50 +02:00
parent 26b0d297ab
commit f252340b3a
No known key found for this signature in database
GPG Key ID: B4EF20DDE721CAA1
1 changed files with 14 additions and 0 deletions

View File

@ -1,5 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { PageData } from "./$types"; import type { PageData } from "./$types";
import { onMount } from "svelte";
import { import {
Alert, Alert,
@ -113,6 +114,19 @@
await navigator.clipboard.writeText(url); await navigator.clipboard.writeText(url);
addToast({ body: "Copied the link to your clipboard!", duration: 2000 }); addToast({ body: "Copied the link to your clipboard!", duration: 2000 });
}; };
onMount(async () => {
if ($userStore && $userStore.id === data.id) {
console.log("User is current user, fetching members")
try {
const members = await apiFetchClient<PartialMember[]>("/users/@me/members");
data.members = members;
} catch (e) {
// If it fails, we fail silently but log to console anyway
console.error("Fetching members:", e)
}
}
})
</script> </script>
<div class="container"> <div class="container">