aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-10-10 00:07:06 -0700
committerAdam Soltys <[email protected]>2024-10-10 12:18:06 -0700
commitaa5ab97f1b314bd4e7a2358e49572eb1a02baf7b (patch)
tree9fb16551ad69418702bac9ec0c14425aa2089e95 /src
parent3b81537518b8ee89848628899eeec9462c8c4bb0 (diff)
downloadcoinos-ui-aa5ab97f1b314bd4e7a2358e49572eb1a02baf7b.tar.gz
coinos-ui-aa5ab97f1b314bd4e7a2358e49572eb1a02baf7b.zip
followers
Diffstat (limited to 'src')
-rw-r--r--src/lib/utils.ts24
-rw-r--r--src/routes/(app)/[username]/(profile)/+layout.server.ts14
-rw-r--r--src/routes/(app)/[username]/(profile)/+layout.svelte20
-rw-r--r--src/routes/(app)/[username]/(profile)/followers/+page.svelte8
-rw-r--r--src/routes/(app)/[username]/(profile)/follows/+page.svelte6
5 files changed, 37 insertions, 35 deletions
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index b32095cb..2ecd332b 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -60,7 +60,6 @@ export let post = async (
.then(async (r) => {
if (r.ok) return r.text();
let text = await r.text();
- console.log("TEXT", text)
let message;
try {
@@ -217,20 +216,16 @@ export let f = (s: number, currency: string): string => {
export let s = (s: number): string =>
new Intl.NumberFormat("en-US", { maximumFractionDigits: 0 }).format(s);
-export let sat = (s: number): string => {
- s = Math.abs(s);
- let p = Math.floor(Math.log(s) / Math.LN10 + 0.000000001);
- let d = Math.floor((p + 1) / 3);
+export let sat = (s: number): string => "⚡️" + si(Math.abs(s)).toString();
- return (
- "⚡️" +
- (parseInt(s.toString()) > 0
- ? new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(
- s / Math.pow(1000, d)
- ) + ["", "K", "M", "G", "T", "P", "E", "Z"][d]
- : 0
- ).toString()
- );
+export let si = (s: number) => {
+ if (s < 1000) return s.toString(); // Return the original number if it's less than 1000
+
+ const units = ["", "K", "M", "G", "T", "P", "E", "Z"];
+ const d = Math.floor(Math.log10(s) / 3); // Calculate the unit index
+ const scaled = s / Math.pow(1000, d); // Scale the number to the correct unit
+
+ return new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(scaled) + units[d];
};
export let sats = 100000000;
@@ -363,4 +358,3 @@ export let versions = {
public: 0x043587cf,
},
}[PUBLIC_COINOS_NETWORK];
-
diff --git a/src/routes/(app)/[username]/(profile)/+layout.server.ts b/src/routes/(app)/[username]/(profile)/+layout.server.ts
index ebb0d6ee..14580694 100644
--- a/src/routes/(app)/[username]/(profile)/+layout.server.ts
+++ b/src/routes/(app)/[username]/(profile)/+layout.server.ts
@@ -1,6 +1,6 @@
import { get } from "$lib/utils";
- export async function load({ depends, parent }) {
+export async function load({ depends, parent }) {
depends("app:user");
let { subject, user } = await parent();
@@ -14,13 +14,13 @@ import { get } from "$lib/utils";
console.log("problem fetching follows", e);
}
- // try {
- // subject.followers = await get(`/${subject.pubkey}/followers`);
- // } catch (e) {
- // console.log("problem fetching followers", e);
- // }
+ try {
+ subject.followers = await get(`/${subject.pubkey}/followers`);
+ } catch (e) {
+ console.log("problem fetching followers", e);
+ }
- subject.followers = [];
+ // subject.followers = [];
if (user) {
user.follows = await get(`/${user.pubkey}/follows?tagsonly=true`);
}
diff --git a/src/routes/(app)/[username]/(profile)/+layout.svelte b/src/routes/(app)/[username]/(profile)/+layout.svelte
index 650eab41..550b43cf 100644
--- a/src/routes/(app)/[username]/(profile)/+layout.svelte
+++ b/src/routes/(app)/[username]/(profile)/+layout.svelte
@@ -2,7 +2,7 @@
import { invalidate } from "$app/navigation";
import { browser } from "$app/environment";
import { hexToUint8Array } from "uint8array-extras";
- import { copy, f, get, post, s, sats, success, fail } from "$lib/utils";
+ import { copy, f, get, post, s, sats, success, fail, si } from "$lib/utils";
import Icon from "$comp/Icon.svelte";
import { t } from "$lib/translations";
import { sign, send } from "$lib/nostr";
@@ -105,27 +105,35 @@
<Icon icon="qr" style="w-8 invert my-auto" />
</button>
- {#if subject.address}
+ {#if subject.address || subject.about}
<div
- class="text-secondary mx-auto text-center lg:mx-0"
+ class="text-secondary mx-auto text-center lg:mx-0 break-words space-y-1"
class:line-clamp-2={!showBio}
on:click={toggleBio}
on:keydown={toggleBio}
>
- {subject.address}
+ <div>
+ {subject.address || subject.about}
+ </div>
+
+ {#if subject.website}
+ <div>
+ <a href={subject.website} class="underline">{subject.website}</a>
+ </div>
+ {/if}
</div>
{/if}
<div>
<div class="flex justify-center gap-2">
<a href={`/${subject.pubkey}/follows`} data-sveltekit-preload-data="tap"
- ><b>{subject.follows.length}</b>
+ ><b>{si(subject.follows.length)}</b>
<span class="text-secondary">{$t("user.following")}</span></a
>
<a
href={`/${subject.pubkey}/followers`}
data-sveltekit-preload-data="tap"
- ><b>{subject.followers.length}</b>
+ ><b>{si(subject.count)}</b>
<span class="text-secondary">{$t("user.followers")}</span></a
>
</div>
diff --git a/src/routes/(app)/[username]/(profile)/followers/+page.svelte b/src/routes/(app)/[username]/(profile)/followers/+page.svelte
index e087ad42..d1e808d6 100644
--- a/src/routes/(app)/[username]/(profile)/followers/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/followers/+page.svelte
@@ -22,9 +22,9 @@
{#if browser}
{#if followers.length}
<VirtualScroll data={followers} key="pubkey" let:data pageMode={true}>
- <a href={`/${data.pubkey}`}>
+ <a href={`/${data.pubkey}`} data-sveltekit-preload-data="tap">
<div
- class="flex border-b last:border-b-0 py-4 text-sm lg:text-lg text-secondary"
+ class="flex border-b last:border-b-0 py-4 text-2xl text-secondary"
:key={data.pubkey}
>
<div class="mb-auto mr-2">
@@ -38,8 +38,8 @@
<div class="w-full flex pb-1 text-black my-auto">
<div>
- {data.display_name || ""}
- <span class="text-secondary">@{data.username}</span>
+ <div>{data.display_name || ""}</div>
+ <div class="text-secondary text-lg">@{data.name}</div>
</div>
</div>
</div>
diff --git a/src/routes/(app)/[username]/(profile)/follows/+page.svelte b/src/routes/(app)/[username]/(profile)/follows/+page.svelte
index ff0bdb93..0281add9 100644
--- a/src/routes/(app)/[username]/(profile)/follows/+page.svelte
+++ b/src/routes/(app)/[username]/(profile)/follows/+page.svelte
@@ -24,7 +24,7 @@
<svelte:window bind:innerWidth={w} />
-<div class="px-3 md:px-0 w-full md:w-[400px] mx-auto space-y-8">
+<div class="px-3 md:px-0 w-full md:w-[400px] mx-auto">
<h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold">
{$t("user.following")}
</h1>
@@ -32,9 +32,9 @@
{#if follows.length}
{#if browser}
<VirtualScroll data={follows} key="pubkey" let:data pageMode={true}>
- <a href={`/${data.pubkey}/follows`} data-sveltekit-preload-data="tap">
+ <a href={`/${data.pubkey}`} data-sveltekit-preload-data="tap">
<div
- class="flex py-4 text-sm lg:text-lg text-secondary"
+ class="flex py-4 text-lg text-secondary"
:key={data.pubkey}
>
<div class="mb-auto mr-2">