aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-01-07 23:44:02 -0800
committerAdam Soltys <[email protected]>2023-01-07 23:44:02 -0800
commite0671101e4b217ff891fad85482e5943aa5cf543 (patch)
tree638adbe0f5de8c5bdad4c9fc2cc25f5135bce8ff
parent14734c6f178ff5c3be1f4afa8f8a07af437c1322 (diff)
downloadcoinos-ui-e0671101e4b217ff891fad85482e5943aa5cf543.tar.gz
coinos-ui-e0671101e4b217ff891fad85482e5943aa5cf543.zip
avatar fix
-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 })