diff options
| author | Adam Soltys <[email protected]> | 2024-10-09 12:52:05 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-10-10 12:18:06 -0700 |
| commit | 4605d7fbd8b94db013b0e5058116e421150f2a47 (patch) | |
| tree | a93d5cd90ec2b2a22917b4a829fd39b4727667b1 /src/components/Avatar.svelte | |
| parent | c2716632244bfc13cafe5cd373d8822ad9436664 (diff) | |
| download | coinos-ui-4605d7fbd8b94db013b0e5058116e421150f2a47.tar.gz coinos-ui-4605d7fbd8b94db013b0e5058116e421150f2a47.zip | |
follows
Diffstat (limited to 'src/components/Avatar.svelte')
| -rw-r--r-- | src/components/Avatar.svelte | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/components/Avatar.svelte b/src/components/Avatar.svelte index 4922c065..e91285da 100644 --- a/src/components/Avatar.svelte +++ b/src/components/Avatar.svelte @@ -10,12 +10,13 @@ $: s = size.toString(); $: link = user?.anon ? `/${user.pubkey}` : `/${user.username}`; - $: src = - ($avatar?.id && $avatar.id === user.id && $avatar.src) || - "/api/public/" + - (user.profile - ? user.profile + ".webp" - : "punks/" + punk(user.pubkey || user.id || "aa")); + let base = "/api/public"; + $: profile = user?.profile ? `${base}/${user.profile}.webp` : user?.picture; + $: fallback = `${base}/punks/` + punk(user.pubkey || user.id || "aa"); + $: tmp = $avatar?.id && $avatar.id === user.id && $avatar.src; + $: src = tmp || profile || fallback; + + let handle = () => (src = fallback); </script> <a href={link} class:pointer-events-none={disabled}> @@ -26,6 +27,7 @@ {src} class="w-full h-full object-cover object-center overflow-hidden" alt={user.username} + on:error={handle} /> </div> </a> |
