From 115f11aa6cc449a25beccff6a675cd71873c5c01 Mon Sep 17 00:00:00 2001 From: Paul Miller Date: Wed, 10 Apr 2024 16:07:06 -0500 Subject: [PATCH] use suspense for loading items --- src/components/Activity.tsx | 107 +++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 39 deletions(-) diff --git a/src/components/Activity.tsx b/src/components/Activity.tsx index a2c9b322..d0b9d313 100644 --- a/src/components/Activity.tsx +++ b/src/components/Activity.tsx @@ -9,6 +9,7 @@ import { For, Match, Show, + Suspense, Switch } from "solid-js"; @@ -98,6 +99,7 @@ export function UnifiedActivityItem(props: { l.startsWith("npub") ); if (npub) { + await new Promise((r) => setTimeout(r, 1000)); try { const newContact = await getContact(npub); return newContact; @@ -185,43 +187,70 @@ export function UnifiedActivityItem(props: { return (
- } - icon={shouldShowShuffle() ? : undefined} - primaryOnClick={() => - primaryContact()?.id - ? navigate(`/chat/${primaryContact()?.id}`) - : profileFromNostr() - ? props.onNewContactClick(profileFromNostr()!) - : undefined - } - amountOnClick={click} - primaryName={ - props.item.inbound - ? primaryContact()?.name - ? primaryContact()!.name - : profileFromNostr()?.name || "Unknown" - : "You" - } - genericAvatar={shouldShowGeneric()} - verb={verb()} - message={message()} - secondaryName={secondaryName()} - amount={ - props.item.amount_sats - ? BigInt(props.item.amount_sats || 0) - : undefined - } - date={timeAgo(props.item.last_updated)} - accent={props.item.inbound ? "green" : undefined} - visibility={ - props.item.privacy_level === "Public" ? "public" : "private" - } - /> + > + : undefined} + primaryOnClick={() => + primaryContact()?.id + ? navigate(`/chat/${primaryContact()?.id}`) + : profileFromNostr() + ? props.onNewContactClick(profileFromNostr()!) + : undefined + } + amountOnClick={click} + primaryName={ + props.item.inbound + ? primaryContact()?.name + ? primaryContact()!.name + : profileFromNostr()?.name || "Unknown" + : "You" + } + genericAvatar={shouldShowGeneric()} + verb={verb()} + message={message()} + secondaryName={secondaryName()} + amount={ + props.item.amount_sats + ? BigInt(props.item.amount_sats || 0) + : undefined + } + date={timeAgo(props.item.last_updated)} + accent={props.item.inbound ? "green" : undefined} + visibility={ + props.item.privacy_level === "Public" + ? "public" + : "private" + } + /> +
); } @@ -364,7 +393,7 @@ export function CombinedActivity() { /> - + navigate("/settings/federations")} @@ -398,7 +427,7 @@ export function CombinedActivity() { - = 0}> + = 0}> navigate("/settings/backup")} @@ -410,7 +439,7 @@ export function CombinedActivity() {
- + {(activityItem) => (