mirror of
https://github.com/luminous-devs/lume.git
synced 2024-09-19 11:43:30 +00:00
updated note onclick
This commit is contained in:
parent
b687bd9893
commit
23f85c7e4f
@ -45,21 +45,21 @@ export const Content = memo(function Content({ data }: { data: any }) {
|
|||||||
<div className="relative z-10 flex flex-col">
|
<div className="relative z-10 flex flex-col">
|
||||||
<UserExtend pubkey={data.pubkey} time={data.created_at} />
|
<UserExtend pubkey={data.pubkey} time={data.created_at} />
|
||||||
<div className="-mt-5 pl-[52px]">
|
<div className="-mt-5 pl-[52px]">
|
||||||
<div className="flex flex-col gap-6">
|
<div className="flex flex-col gap-2">
|
||||||
<div className="flex flex-col gap-2">
|
<div className="prose prose-zinc max-w-none break-words text-[15px] leading-tight dark:prose-invert prose-headings:mt-3 prose-headings:mb-2 prose-p:m-0 prose-p:text-[15px] prose-p:leading-tight prose-a:font-normal prose-a:text-fuchsia-500 prose-a:no-underline prose-ul:mt-2 prose-li:my-1">
|
||||||
<div className="prose prose-zinc max-w-none break-words text-[15px] leading-tight dark:prose-invert prose-headings:mt-3 prose-headings:mb-2 prose-p:m-0 prose-p:text-[15px] prose-p:leading-tight prose-a:font-normal prose-a:text-fuchsia-500 prose-a:no-underline prose-ul:mt-2 prose-li:my-1">
|
{content}
|
||||||
{content}
|
|
||||||
</div>
|
|
||||||
<NotePreview content={data.content} />
|
|
||||||
</div>
|
</div>
|
||||||
<NoteMetadata
|
<NotePreview content={data.content} />
|
||||||
eventID={data.id}
|
|
||||||
eventPubkey={data.pubkey}
|
|
||||||
eventContent={data.content}
|
|
||||||
eventTime={data.created_at}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div onClick={(e) => e.stopPropagation()} className="mt-5 pl-[52px]">
|
||||||
|
<NoteMetadata
|
||||||
|
eventID={data.id}
|
||||||
|
eventPubkey={data.pubkey}
|
||||||
|
eventContent={data.content}
|
||||||
|
eventTime={data.created_at}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -3,20 +3,23 @@ import { RootNote } from '@components/note/root';
|
|||||||
|
|
||||||
import destr from 'destr';
|
import destr from 'destr';
|
||||||
import { useRouter } from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { memo, useMemo } from 'react';
|
import { memo, useMemo, useRef } from 'react';
|
||||||
|
|
||||||
export const Note = memo(function Note({ event }: { event: any }) {
|
export const Note = memo(function Note({ event }: { event: any }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const tags = destr(event.tags);
|
const tags = destr(event.tags);
|
||||||
|
const rootEventID = useRef(null);
|
||||||
|
|
||||||
const fetchRootEvent = useMemo(() => {
|
const fetchRootEvent = useMemo(() => {
|
||||||
if (tags.length > 0) {
|
if (tags.length > 0) {
|
||||||
if (tags[0][0] === 'e' || tags[0][2] === 'root') {
|
if (tags[0][0] === 'e' || tags[0][2] === 'root') {
|
||||||
|
rootEventID.current = tags[0][1];
|
||||||
return <RootNote id={tags[0][1]} />;
|
return <RootNote id={tags[0][1]} />;
|
||||||
} else {
|
} else {
|
||||||
tags.every((tag) => {
|
tags.every((tag) => {
|
||||||
if (tag[0] === 'e' && tag[2] === 'root') {
|
if (tag[0] === 'e' && tag[2] === 'root') {
|
||||||
return <RootNote id={tags[1]} />;
|
rootEventID.current = tag[1];
|
||||||
|
return <RootNote id={tag[1]} />;
|
||||||
}
|
}
|
||||||
return <></>;
|
return <></>;
|
||||||
});
|
});
|
||||||
@ -27,7 +30,7 @@ export const Note = memo(function Note({ event }: { event: any }) {
|
|||||||
}, [tags]);
|
}, [tags]);
|
||||||
|
|
||||||
const openThread = () => {
|
const openThread = () => {
|
||||||
router.push(`/newsfeed/${event.id}`);
|
router.push(`/newsfeed/${rootEventID.current || event.id}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -3,7 +3,7 @@ import ReactPlayer from 'react-player/lazy';
|
|||||||
|
|
||||||
export const VideoPreview = memo(function VideoPreview({ data }: { data: string }) {
|
export const VideoPreview = memo(function VideoPreview({ data }: { data: string }) {
|
||||||
return (
|
return (
|
||||||
<div className="relative mt-2 flex flex-col overflow-hidden rounded-lg">
|
<div onClick={(e) => e.stopPropagation()} className="relative mt-2 flex flex-col overflow-hidden rounded-lg">
|
||||||
<ReactPlayer
|
<ReactPlayer
|
||||||
url={data}
|
url={data}
|
||||||
controls={true}
|
controls={true}
|
||||||
|
Loading…
Reference in New Issue
Block a user