diff --git a/src/components/common/Comment.tsx b/src/components/common/Comment.tsx index 0168e740..8c5d9865 100644 --- a/src/components/common/Comment.tsx +++ b/src/components/common/Comment.tsx @@ -10,21 +10,11 @@ import { useConnectModal } from "@rainbow-me/rainbowkit" import { useState, useEffect } from "react" import { useCommentPage, useGetComments } from "~/queries/page" import { useRouter } from "next/router" -import dayjs from "dayjs" -import duration from "dayjs/plugin/duration" -import relativeTime from "dayjs/plugin/relativeTime" -import { UniLink } from "~/components/ui/UniLink" -import { BlockchainIcon } from "~/components/icons/BlockchainIcon" // @ts-ignore import Picker from "@emoji-mart/react" import { Popover } from "@headlessui/react" import { FaceSmileIcon } from "@heroicons/react/24/outline" -import { CSB_SCAN } from "~/lib/env" -import { getSiteLink } from "~/lib/helpers" -import { PageContent } from "~/components/common/PageContent" - -dayjs.extend(duration) -dayjs.extend(relativeTime) +import { CommentItem } from "~/components/common/CommentItem" export const Comment: React.FC<{ page?: Note | null @@ -118,7 +108,7 @@ export const Comment: React.FC<{ - + { const response = await fetch( @@ -150,57 +140,9 @@ export const Comment: React.FC<{ -
+
{comments.data?.list?.map((comment) => ( -
- - - -
-
- - {comment?.character?.metadata?.content?.name} - {" "} - ·{" "} - {dayjs - .duration( - dayjs(comment?.createdAt).diff(dayjs(), "minute"), - "minute", - ) - .humanize()}{" "} - ago ·{" "} - - - -
- -
-
+ ))}
diff --git a/src/components/common/CommentItem.tsx b/src/components/common/CommentItem.tsx new file mode 100644 index 00000000..303afdf2 --- /dev/null +++ b/src/components/common/CommentItem.tsx @@ -0,0 +1,91 @@ +import { Avatar } from "~/components/ui/Avatar" +import dayjs from "dayjs" +import duration from "dayjs/plugin/duration" +import relativeTime from "dayjs/plugin/relativeTime" +import { UniLink } from "~/components/ui/UniLink" +import { BlockchainIcon } from "~/components/icons/BlockchainIcon" +import { CSB_SCAN } from "~/lib/env" +import { getSiteLink } from "~/lib/helpers" +import { PageContent } from "~/components/common/PageContent" +import { NoteEntity, CharacterEntity } from "crossbell.js" + +dayjs.extend(duration) +dayjs.extend(relativeTime) + +export const CommentItem: React.FC<{ + comment: NoteEntity & { + character?: CharacterEntity | null + } + isSub?: boolean +}> = ({ comment, isSub }) => { + return ( +
+
+ + + +
+
+ + {comment?.character?.metadata?.content?.name} + {" "} + ·{" "} + {dayjs + .duration( + dayjs(comment?.createdAt).diff(dayjs(), "minute"), + "minute", + ) + .humanize()}{" "} + ago ·{" "} + + + +
+ +
+
+ {(comment as any)?.fromNotes?.list?.length > 0 && ( +
+ {(comment as any)?.fromNotes?.list?.map( + ( + subcomment: NoteEntity & { + character?: CharacterEntity | null + }, + ) => ( + + ), + )} +
+ )} +
+ ) +} diff --git a/src/models/page.model.ts b/src/models/page.model.ts index 4187131d..5b3fc148 100644 --- a/src/models/page.model.ts +++ b/src/models/page.model.ts @@ -584,6 +584,9 @@ export async function getComments({ pageId }: { pageId: string }) { toNoteId: pageId.split("-")[1], cursor: "", includeCharacter: true, + includeNestedNotes: true, + nestedNotesDepth: 3 as 3, + nestedNotesLimit: 20, } let pages: ListResponse<