From 0147a70e8f5ede8db49343692fa5e8153d6455ea Mon Sep 17 00:00:00 2001
From: Ren Amamiya <123083837+reyamir@users.noreply.github.com>
Date: Mon, 12 Jun 2023 14:24:07 +0700
Subject: [PATCH] update thread & add reply form
---
src/app/space/components/blocks/thread.tsx | 4 ++
src/app/space/components/notes/metadata.tsx | 6 +-
.../space/components/notes/replies/form.tsx | 64 ++++++++++++-------
.../space/components/notes/replies/list.tsx | 6 ++
src/utils/transform.tsx | 6 +-
5 files changed, 57 insertions(+), 29 deletions(-)
diff --git a/src/app/space/components/blocks/thread.tsx b/src/app/space/components/blocks/thread.tsx
index 3eeeac49..10c09034 100644
--- a/src/app/space/components/blocks/thread.tsx
+++ b/src/app/space/components/blocks/thread.tsx
@@ -1,6 +1,7 @@
import { Kind1 } from "@app/space/components/notes/kind1";
import { Kind1063 } from "@app/space/components/notes/kind1063";
import { NoteMetadata } from "@app/space/components/notes/metadata";
+import { NoteReplyForm } from "@app/space/components/notes/replies/form";
import { RepliesList } from "@app/space/components/notes/replies/list";
import { NoteSkeleton } from "@app/space/components/notes/skeleton";
import { NoteDefaultUser } from "@app/space/components/user/default";
@@ -54,6 +55,9 @@ export function ThreadBlock({ params }: { params: any }) {
+
+
+
)}
diff --git a/src/app/space/components/notes/metadata.tsx b/src/app/space/components/notes/metadata.tsx
index eef4a942..d02d4663 100644
--- a/src/app/space/components/notes/metadata.tsx
+++ b/src/app/space/components/notes/metadata.tsx
@@ -68,7 +68,11 @@ export function NoteMetadata({
const { data } = useSWR(["note-metadata", ndk, id], fetcher);
return (
-
+
e.stopPropagation()}
+ onKeyDown={(e) => e.stopPropagation()}
+ className="inline-flex items-center gap-2 w-full h-12 mt-4"
+ >
{!data ? (
<>
diff --git a/src/app/space/components/notes/replies/form.tsx b/src/app/space/components/notes/replies/form.tsx
index ebf83c2e..aeab8537 100644
--- a/src/app/space/components/notes/replies/form.tsx
+++ b/src/app/space/components/notes/replies/form.tsx
@@ -1,12 +1,16 @@
import { NDKEvent, NDKPrivateKeySigner } from "@nostr-dev-kit/ndk";
+import { Image } from "@shared/image";
import { RelayContext } from "@shared/relayProvider";
import { useActiveAccount } from "@stores/accounts";
+import { DEFAULT_AVATAR } from "@stores/constants";
import { dateToUnix } from "@utils/date";
+import { useProfile } from "@utils/hooks/useProfile";
import { useContext, useState } from "react";
export function NoteReplyForm({ id }: { id: string }) {
const ndk = useContext(RelayContext);
const account = useActiveAccount((state: any) => state.account);
+ const { user } = useProfile(account.npub);
const [value, setValue] = useState("");
@@ -30,30 +34,44 @@ export function NoteReplyForm({ id }: { id: string }) {
};
return (
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ Reply as
+
+
+ {user?.nip05 || user?.name}
+
+
+
+
+
diff --git a/src/app/space/components/notes/replies/list.tsx b/src/app/space/components/notes/replies/list.tsx
index d06c9f9e..1df39bbf 100644
--- a/src/app/space/components/notes/replies/list.tsx
+++ b/src/app/space/components/notes/replies/list.tsx
@@ -33,6 +33,12 @@ export function RepliesList({ id }: { id: string }) {
+ ) : data.length === 0 ? (
+
) : (
data.map((event: NDKEvent) =>
)
)}
diff --git a/src/utils/transform.tsx b/src/utils/transform.tsx
index 89d5088e..8d413694 100644
--- a/src/utils/transform.tsx
+++ b/src/utils/transform.tsx
@@ -87,11 +87,7 @@ export function getQuoteID(arr: string[]) {
if (tags[0][0] === "e") {
quoteID = tags[0][1];
} else {
- tags.forEach((tag) => {
- if (tag[0] === "e") {
- quoteID = tag[1];
- }
- });
+ quoteID = tags.find((t) => t[0] === "e")?.[1];
}
}