aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/components/Avatar.svelte4
-rw-r--r--src/lib/utils.js6
2 files changed, 3 insertions, 7 deletions
diff --git a/src/components/Avatar.svelte b/src/components/Avatar.svelte
index 75d39d9f..8c819709 100644
--- a/src/components/Avatar.svelte
+++ b/src/components/Avatar.svelte
@@ -12,9 +12,7 @@
$: src =
'/api/public/' +
- (user?.profile
- ? user.uuid + '-profile.webp'
- : 'punks/' + punk(user?.pubkey));
+ (user?.profile ? user.uuid + '-profile.webp' : 'punks/' + punk(user?.pubkey || user?.uuid || 'aa'));
</script>
<a href={link} class:pointer-events-none={disabled}>
diff --git a/src/lib/utils.js b/src/lib/utils.js
index 279dcb98..c1ec5e5b 100644
--- a/src/lib/utils.js
+++ b/src/lib/utils.js
@@ -10,10 +10,8 @@ export function scroll(section) {
}
const base = browser ? '' : PUBLIC_COINOS_URL;
-export const punk = (k) => {
- let n = k ? parseInt(k.slice(-2), 16) : parseInt(Math.random() * 255);
- return Math.floor((n / 256) * 64) + 1 + '.webp';
-};
+
+export const punk = (k) => Math.floor((parseInt(k.slice(-2), 16) / 256) * 64) + 1 + '.webp';
export const g = (url, fetch, headers) =>
fetch(base + url, { headers })