From 6ba622328ba64cc524f2197fb1dc78345cc9a24e Mon Sep 17 00:00:00 2001 From: Shusui MOYATANI Date: Sat, 17 Jun 2023 01:42:04 +0900 Subject: [PATCH] update --- ...hannelMessage.tsx => NotificationItem.tsx} | 0 src/components/Post.tsx | 28 +++++++++-- src/components/column/Column.tsx | 2 +- src/components/event/Reaction.tsx | 4 +- src/components/event/ZapReceipt.tsx | 45 ++++++++++++++++++ .../event/textNote/TextNoteDisplay.tsx | 46 ++++++------------- src/components/modal/EventDebugModal.tsx | 28 +++++++++++ src/components/modal/ProfileDisplay.tsx | 32 +++++++++++-- src/components/modal/ProfileEdit.tsx | 2 + src/components/timeline/Notification.tsx | 8 ++++ src/components/utils/Copy.tsx | 2 +- src/hooks/useCommandBus.ts | 2 +- src/hooks/useDetectOverflow.ts | 5 +- src/nostr/useFollowings.ts | 2 +- 14 files changed, 159 insertions(+), 47 deletions(-) rename src/components/{event/ChannelMessage.tsx => NotificationItem.tsx} (100%) create mode 100644 src/components/event/ZapReceipt.tsx create mode 100644 src/components/modal/EventDebugModal.tsx diff --git a/src/components/event/ChannelMessage.tsx b/src/components/NotificationItem.tsx similarity index 100% rename from src/components/event/ChannelMessage.tsx rename to src/components/NotificationItem.tsx diff --git a/src/components/Post.tsx b/src/components/Post.tsx index cf96c53..0f1b496 100644 --- a/src/components/Post.tsx +++ b/src/components/Post.tsx @@ -2,14 +2,15 @@ import { Component, JSX, Show, createSignal } from 'solid-js'; import useDetectOverflow from '@/hooks/useDetectOverflow'; import useFormatDate from '@/hooks/useFormatDate'; +import useProfile from '@/nostr/useProfile'; +import npubEncodeFallback from '@/utils/npubEncodeFallback'; export type PostProps = { - author: JSX.Element; + authorPubkey: string; createdAt: Date; content: JSX.Element; actions?: JSX.Element; footer?: JSX.Element; - authorPictureUrl?: string; onShowProfile?: () => void; onShowEvent?: () => void; }; @@ -21,6 +22,10 @@ const Post: Component = (props) => { const [showOverflow, setShowOverflow] = createSignal(); const createdAt = () => formatDate(props.createdAt); + const { profile: author } = useProfile(() => ({ + pubkey: props.authorPubkey, + })); + return (
@@ -32,7 +37,7 @@ const Post: Component = (props) => { props.onShowProfile?.(); }} > - + {(url) => icon} @@ -46,7 +51,22 @@ const Post: Component = (props) => { props?.onShowProfile?.(); }} > - {props.author} + + 0}> +
+ {author()?.display_name} +
+
+
+ + @{author()?.name} + + {/* TODO @{author()?.nip05} */} +
+
-
    +
diff --git a/src/components/event/Reaction.tsx b/src/components/event/Reaction.tsx index 9bed217..c15e2ef 100644 --- a/src/components/event/Reaction.tsx +++ b/src/components/event/Reaction.tsx @@ -38,8 +38,8 @@ const Reaction: Component = (props) => { // if the reacted event is not found, it should be a removed event
-
- +
+ {props.event.content}}> diff --git a/src/components/event/ZapReceipt.tsx b/src/components/event/ZapReceipt.tsx new file mode 100644 index 0000000..3cc8a0a --- /dev/null +++ b/src/components/event/ZapReceipt.tsx @@ -0,0 +1,45 @@ +import { Component, Show, createMemo } from 'solid-js'; + +import { type Event as NostrEvent } from 'nostr-tools'; + +import GeneralUserMentionDisplay from '@/components/event/textNote/GeneralUserMentionDisplay'; +import UserNameDisplay from '@/components/UserDisplayName'; +import useConfig from '@/core/useConfig'; +import { genericEvent } from '@/nostr/event'; + +export type ZapReceiptProps = { + event: NostrEvent; +}; + +const ZapReceipt: Component = (props) => { + const { shouldMuteEvent } = useConfig(); + + const event = createMemo(() => genericEvent(props.event)); + + const zapRequest = () => { + const description = event().findFirstTagByName('description'); + if (description == null) return null; + + try { + // TODO verify that this is event + return JSON.parse(description[1]) as NostrEvent; + } catch (err) { + console.error('failed to parse zap receipt', description); + return null; + } + }; + + const amount = () => { + return event().findFirstTagByName('amount'); + }; + + return ( + + ⚡ + +
{JSON.stringify(props.event, null, 2)}
+
+ ); +}; + +export default ZapReceipt; diff --git a/src/components/event/textNote/TextNoteDisplay.tsx b/src/components/event/textNote/TextNoteDisplay.tsx index 820bf02..e55d9c0 100644 --- a/src/components/event/textNote/TextNoteDisplay.tsx +++ b/src/components/event/textNote/TextNoteDisplay.tsx @@ -16,6 +16,7 @@ import EventDisplayById from '@/components/event/EventDisplayById'; import ContentWarningDisplay from '@/components/event/textNote/ContentWarningDisplay'; import GeneralUserMentionDisplay from '@/components/event/textNote/GeneralUserMentionDisplay'; import TextNoteContentDisplay from '@/components/event/textNote/TextNoteContentDisplay'; +import EventDebugModal from '@/components/modal/EventDebugModal'; import NotePostForm from '@/components/NotePostForm'; import Post from '@/components/Post'; import { useTimelineContext } from '@/components/timeline/TimelineContext'; @@ -23,12 +24,10 @@ import useConfig from '@/core/useConfig'; import useModalState from '@/hooks/useModalState'; import { textNote } from '@/nostr/event'; import useCommands from '@/nostr/useCommands'; -import useProfile from '@/nostr/useProfile'; import usePubkey from '@/nostr/usePubkey'; import useReactions from '@/nostr/useReactions'; import useReposts from '@/nostr/useReposts'; import ensureNonNull from '@/utils/ensureNonNull'; -import npubEncodeFallback from '@/utils/npubEncodeFallback'; import timeout from '@/utils/timeout'; export type TextNoteDisplayProps = { @@ -49,7 +48,7 @@ const EmojiReactions: Component = (props) => { const pubkey = usePubkey(); return ( -
+
{([content, events]) => { const isReactedByMeWithThisContent = @@ -57,7 +56,7 @@ const EmojiReactions: Component = (props) => { return (