Browse Source

Fix reactive values in UserHeader

master
jk 2 years ago
parent
commit
c03a4cd01d
No known key found for this signature in database
  1. 24
      src/lib/components/users/UserHeader.svelte

24
src/lib/components/users/UserHeader.svelte

@ -1,21 +1,13 @@
<script lang="ts" context="module"> <script lang="ts">
export const defaults: User = { import { getName, type User } from "./type";
export let user: User = {
hexpubkey: "", hexpubkey: "",
npub: "", npub: "",
loading: true, loading: true,
}; };
</script> $: ({ profile, loading } = user);
$: display_name = getName(user);
<script lang="ts">
import { getName, type User } from "./type";
export let user: User = defaults;
let { profile, hexpubkey, loading } = user;
let display_name = "";
$: {
let { profile, hexpubkey, loading } = user;
display_name = getName(user);
}
</script> </script>
<div class="flex my-2"> <div class="flex my-2">
@ -25,8 +17,8 @@
class:skeleton={!profile && loading} class:skeleton={!profile && loading}
class:bg-neutral={!loading && (!profile || !profile.image)} class:bg-neutral={!loading && (!profile || !profile.image)}
> >
{#if profile && profile.image} {#if !!profile?.image}
<img class="my-0" src={profile.image} alt={display_name} /> <img class="my-0" src={profile?.image} alt={display_name} />
{/if} {/if}
</div> </div>
</div> </div>

Loading…
Cancel
Save