aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-01-07 23:39:25 -0800
committerAdam Soltys <[email protected]>2023-01-07 23:39:25 -0800
commit14734c6f178ff5c3be1f4afa8f8a07af437c1322 (patch)
tree3df4477be8f08721544645a62a325556bad79997 /src
parent17d2c4b23f6ec1857a486872e1d156a62fdb3cca (diff)
downloadcoinos-ui-14734c6f178ff5c3be1f4afa8f8a07af437c1322.tar.gz
coinos-ui-14734c6f178ff5c3be1f4afa8f8a07af437c1322.zip
handle undefined pubkeys for avatars
Diffstat (limited to 'src')
-rw-r--r--src/components/Avatar.svelte2
-rw-r--r--src/lib/utils.js3
2 files changed, 3 insertions, 2 deletions
diff --git a/src/components/Avatar.svelte b/src/components/Avatar.svelte
index 05b2c63b..75d39d9f 100644
--- a/src/components/Avatar.svelte
+++ b/src/components/Avatar.svelte
@@ -14,7 +14,7 @@
'/api/public/' +
(user?.profile
? user.uuid + '-profile.webp'
- : 'punks/' + punk(user?.pubkey || parseInt(Math.random() * 255).toString(16)));
+ : 'punks/' + punk(user?.pubkey));
</script>
<a href={link} class:pointer-events-none={disabled}>
diff --git a/src/lib/utils.js b/src/lib/utils.js
index 2b425626..279dcb98 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -11,7 +11,8 @@ export function scroll(section) {
const base = browser ? '' : PUBLIC_COINOS_URL;
export const punk = (k) => {
- return Math.floor((parseInt(k.slice(-2), 16) / 256) * 64) + 1 + '.webp';
+ let n = k ? parseInt(k.slice(-2), 16) : parseInt(Math.random() * 255);
+ return Math.floor((n / 256) * 64) + 1 + '.webp';
};
export const g = (url, fetch, headers) =>