added note metadta component

This commit is contained in:
Ren Amamiya
2023-03-17 13:05:10 +07:00
parent e43a999ca8
commit b3f95366d3
9 changed files with 189 additions and 99 deletions

View File

@@ -1,12 +1,22 @@
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') {
@@ -16,7 +26,10 @@ export const Note = memo(function Note({ event }: { event: any }) {
}, [tags]);
return (
<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">
<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} />