render reply and sub reply accordingly

This commit is contained in:
Ren Amamiya
2023-07-19 17:07:25 +07:00
parent 22c1eaa541
commit 29d40ed406
14 changed files with 118 additions and 34 deletions

View File

@@ -1,25 +1,33 @@
import { NoteActions, NoteContent } from '@shared/notes';
import { useMemo } from 'react';
import { NoteActions, NoteContent, SubReply } from '@shared/notes';
import { User } from '@shared/user';
import { parser } from '@utils/parser';
import { LumeEvent } from '@utils/types';
export function Reply({ data }: { data: LumeEvent }) {
const content = parser(data);
export function Reply({ event }: { event: LumeEvent }) {
const content = useMemo(() => parser(event), [event]);
return (
<div className="h-min w-full py-1.5">
<div className="relative overflow-hidden rounded-xl border-t border-zinc-800/50 bg-zinc-900 px-3 pt-3">
<div className="relative flex flex-col">
<User pubkey={data.pubkey} time={data.created_at} />
<User pubkey={event.pubkey} time={event.created_at} />
<div className="relative z-20 -mt-6 flex items-start gap-3">
<div className="w-11 shrink-0" />
<div className="flex-1">
<NoteContent content={content} />
<NoteActions id={data.event_id || data.id} pubkey={data.pubkey} />
<NoteActions id={event.event_id || event.id} pubkey={event.pubkey} />
</div>
</div>
<div className="pb-3" />
<div>
{event.replies ? (
event.replies.map((sub) => <SubReply key={sub.id} event={sub} />)
) : (
<div className="pb-3" />
)}
</div>
</div>
</div>
</div>