added comment form and updated note metadata

This commit is contained in:
Ren Amamiya
2023-03-20 09:38:17 +07:00
parent 1c9420f370
commit 1a536bd2f8
15 changed files with 378 additions and 250 deletions

View File

@@ -1,22 +1,12 @@
import { Content } from '@components/note/content';
import { RootNote } from '@components/note/root';
import { useRouter } from 'next/router';
import { memo, useEffect, useState } from 'react';
export const Note = memo(function Note({ event }: { event: any }) {
const router = useRouter();
const [root, setRoot] = useState(null);
const tags = JSON.parse(event.tags);
const openThread = () => {
router.push({
pathname: '/newsfeed/thread',
query: { id: root ? root : event.id },
});
};
useEffect(() => {
if (tags.length > 0) {
if (tags[0][0] === 'e') {
@@ -26,15 +16,8 @@ export const Note = memo(function Note({ event }: { event: any }) {
}, [tags]);
return (
<div
onClick={() => openThread()}
className="relative z-10 flex h-min min-h-min w-full cursor-pointer select-text flex-col border-b border-zinc-800 py-5 px-3 hover:bg-black/20"
>
{root && (
<>
<RootNote id={root} />
</>
)}
<div className="relative z-10 flex h-min min-h-min w-full cursor-pointer select-text flex-col border-b border-zinc-800 py-5 px-3 hover:bg-black/20">
{root && <RootNote id={root} />}
<Content data={event} />
</div>
);