From 6f4fe1f674133c949ad55c535829e0f7c45ea4ee Mon Sep 17 00:00:00 2001 From: Jon Staab Date: Tue, 15 Oct 2024 13:05:01 -0700 Subject: [PATCH] Fine tune message sending notification --- package-lock.json | 8 ++--- src/app/components/ChannelMessage.svelte | 28 +++++++++-------- src/app/state.ts | 35 +++++++++++++++------ src/lib/transition.ts | 39 ++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index d85ee317..b77ca3de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,7 +23,7 @@ "@tiptap/extension-text": "^2.6.6", "@tiptap/suggestion": "^2.6.4", "@types/throttle-debounce": "^5.0.2", - "@welshman/app": "~0.0.15", + "@welshman/app": "~0.0.16", "@welshman/content": "~0.0.12", "@welshman/dvm": "~0.0.10", "@welshman/feeds": "~0.0.20", @@ -1660,9 +1660,9 @@ } }, "node_modules/@welshman/app": { - "version": "0.0.15", - "resolved": "https://registry.npmjs.org/@welshman/app/-/app-0.0.15.tgz", - "integrity": "sha512-rIKJSuWB7uqc1jGtEPEJk/lSFQQVB3qmKESuS55CicBguULljyr0inatSujJo6X3QpN4kLtDLph7gC6HEAWadg==", + "version": "0.0.16", + "resolved": "https://registry.npmjs.org/@welshman/app/-/app-0.0.16.tgz", + "integrity": "sha512-XR60o3iQlMMMvnf8UuSCz5tpMVfR6Ifq/5GGXVlmNF5ngHi0D6NKWoa4r86iJ3Tac3dtl36ZUdzyJksJi618rg==", "dependencies": { "@welshman/dvm": "~0.0.10", "@welshman/feeds": "~0.0.20", diff --git a/src/app/components/ChannelMessage.svelte b/src/app/components/ChannelMessage.svelte index 4442ae49..5ede62f8 100644 --- a/src/app/components/ChannelMessage.svelte +++ b/src/app/components/ChannelMessage.svelte @@ -2,7 +2,7 @@ import {readable, derived} from "svelte/store" import {hash, ellipsize, uniqBy, groupBy, now} from "@welshman/lib" import type {TrustedEvent} from "@welshman/util" - import {deriveEvents} from "@welshman/store" + import {deriveEvents, throttled} from "@welshman/store" import {PublishStatus} from "@welshman/net" import { publishStatusData, @@ -14,6 +14,7 @@ import type {PublishStatusData} from "@welshman/app" import {REACTION, ZAP_RESPONSE, displayRelayUrl} from "@welshman/util" import {repository} from "@welshman/app" + import {slideAndFade} from '@lib/transition' import Icon from "@lib/components/Icon.svelte" import Avatar from "@lib/components/Avatar.svelte" import Content from "@app/components/Content.svelte" @@ -38,7 +39,7 @@ const rootHints = [rootTag?.[2]].filter(Boolean) as string[] const rootEvent = rootId ? deriveEvent(rootId, rootHints) : readable(null) const [colorName, colorValue] = colors[parseInt(hash(event.pubkey)) % colors.length] - const ps = derived(publishStatusData, $m => Object.values($m[event.id] || {})) + const ps = throttled(300, derived(publishStatusData, $m => Object.values($m[event.id] || {}))) const findStatus = ($ps: PublishStatusData[], statuses: PublishStatus[]) => $ps.find(({status}) => statuses.includes(status)) @@ -89,7 +90,7 @@

{/if} -
+
{#if showPubkey} {:else} @@ -103,27 +104,28 @@ {formatTimestampAsTime(event.created_at)}
{/if} -
+
{#if isPending} - - +
+ Sending... - +
{:else if failure} - - +
+ Failed to send! - +
{/if}
{#if $reactions.length > 0 || $zaps.length > 0}
- {#each groupBy( e => e.content, uniqBy(e => e.pubkey + e.content, $reactions), ).entries() as [content, events]} + {#each groupBy(e => e.content, uniqBy(e => e.pubkey + e.content, $reactions)).entries() as [content, events]} {@const isOwn = events.some(e => e.pubkey === $pubkey)} {@const onClick = () => onReactionClick(content, events)}