mirror of
https://github.com/lumehq/lume.git
synced 2025-09-27 20:46:22 +02:00
add nip-94 to newsfeed
This commit is contained in:
@@ -59,7 +59,7 @@ export function Page() {
|
|||||||
|
|
||||||
// kind 1 (notes) query
|
// kind 1 (notes) query
|
||||||
query.push({
|
query.push({
|
||||||
kinds: [1, 6],
|
kinds: [1, 6, 1063],
|
||||||
authors: follows,
|
authors: follows,
|
||||||
since: sinceNotes,
|
since: sinceNotes,
|
||||||
until: dateToUnix(now.current),
|
until: dateToUnix(now.current),
|
||||||
@@ -140,6 +140,18 @@ export function Page() {
|
|||||||
addToBlacklist(account.id, event.tags[0][1], 44, 1);
|
addToBlacklist(account.id, event.tags[0][1], 44, 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 1063:
|
||||||
|
createNote(
|
||||||
|
event.id,
|
||||||
|
account.id,
|
||||||
|
event.pubkey,
|
||||||
|
event.kind,
|
||||||
|
event.tags,
|
||||||
|
event.content,
|
||||||
|
event.created_at,
|
||||||
|
''
|
||||||
|
);
|
||||||
|
break;
|
||||||
// long post
|
// long post
|
||||||
case 30023:
|
case 30023:
|
||||||
// insert event to local database
|
// insert event to local database
|
||||||
|
@@ -1,4 +1,5 @@
|
|||||||
import { NoteContent } from '@lume/app/note/components/content';
|
import { Kind1 } from '@lume/app/note/components/kind1';
|
||||||
|
import { Kind1063 } from '@lume/app/note/components/kind1063';
|
||||||
import NoteMetadata from '@lume/app/note/components/metadata';
|
import NoteMetadata from '@lume/app/note/components/metadata';
|
||||||
import { NoteParent } from '@lume/app/note/components/parent';
|
import { NoteParent } from '@lume/app/note/components/parent';
|
||||||
import { NoteDefaultUser } from '@lume/app/note/components/user/default';
|
import { NoteDefaultUser } from '@lume/app/note/components/user/default';
|
||||||
@@ -25,7 +26,8 @@ export const NoteBase = ({ event }: { event: any }) => {
|
|||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<NoteDefaultUser pubkey={event.pubkey} time={event.created_at} />
|
<NoteDefaultUser pubkey={event.pubkey} time={event.created_at} />
|
||||||
<div className="mt-3 pl-[46px]">
|
<div className="mt-3 pl-[46px]">
|
||||||
<NoteContent content={content} />
|
{event.kind === 1 && <Kind1 content={content} />}
|
||||||
|
{event.kind === 1063 && <Kind1063 metadata={event.tags} />}
|
||||||
<NoteMetadata id={event.event_id} eventPubkey={event.pubkey} />
|
<NoteMetadata id={event.event_id} eventPubkey={event.pubkey} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -1,16 +0,0 @@
|
|||||||
import { Image } from '@lume/shared/image';
|
|
||||||
|
|
||||||
export default function NoteFile({ url }: { url: string }) {
|
|
||||||
return (
|
|
||||||
<div className="mt-3 grid h-full w-full grid-cols-3">
|
|
||||||
<div className="col-span-3">
|
|
||||||
<Image
|
|
||||||
src={url}
|
|
||||||
alt="image"
|
|
||||||
className="h-auto w-full rounded-lg object-cover"
|
|
||||||
style={{ contentVisibility: 'auto' }}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
@@ -6,7 +6,7 @@ import VideoPreview from '@lume/app/note/components/preview/video';
|
|||||||
import ReactMarkdown from 'react-markdown';
|
import ReactMarkdown from 'react-markdown';
|
||||||
import remarkGfm from 'remark-gfm';
|
import remarkGfm from 'remark-gfm';
|
||||||
|
|
||||||
export const NoteContent = ({ content }: { content: any }) => {
|
export const Kind1 = ({ content }: { content: any }) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
@@ -21,10 +21,10 @@ export const NoteContent = ({ content }: { content: any }) => {
|
|||||||
</ReactMarkdown>
|
</ReactMarkdown>
|
||||||
{Array.isArray(content.images) && content.images.length ? <ImagePreview urls={content.images} /> : <></>}
|
{Array.isArray(content.images) && content.images.length ? <ImagePreview urls={content.images} /> : <></>}
|
||||||
{Array.isArray(content.videos) && content.videos.length ? <VideoPreview urls={content.videos} /> : <></>}
|
{Array.isArray(content.videos) && content.videos.length ? <VideoPreview urls={content.videos} /> : <></>}
|
||||||
{!Array.isArray(content.notes) && !content.notes.length ? (
|
{Array.isArray(content.notes) && content.notes.length ? (
|
||||||
<></>
|
|
||||||
) : (
|
|
||||||
content.notes.map((note: string) => <MentionNote key={note} id={note} />)
|
content.notes.map((note: string) => <MentionNote key={note} id={note} />)
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
15
src/app/note/components/kind1063.tsx
Normal file
15
src/app/note/components/kind1063.tsx
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import { Image } from '@lume/shared/image';
|
||||||
|
|
||||||
|
function isImage(url: string) {
|
||||||
|
return /\.(jpg|jpeg|gif|png|webp|avif)$/.test(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const Kind1063 = ({ metadata }: { metadata: string[] }) => {
|
||||||
|
const url = metadata[0][1];
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="mt-3">
|
||||||
|
{isImage(url) && <Image src={url} alt="image" className="h-auto w-full rounded-lg object-cover" />}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
@@ -1,5 +1,5 @@
|
|||||||
import { NoteContent } from '@lume/app/note/components/content';
|
import { Kind1 } from '@lume/app/note/components/kind1';
|
||||||
import NoteFile from '@lume/app/note/components/file';
|
import { Kind1063 } from '@lume/app/note/components/kind1063';
|
||||||
import { NoteSkeleton } from '@lume/app/note/components/skeleton';
|
import { NoteSkeleton } from '@lume/app/note/components/skeleton';
|
||||||
import { NoteDefaultUser } from '@lume/app/note/components/user/default';
|
import { NoteDefaultUser } from '@lume/app/note/components/user/default';
|
||||||
import { NoteWrapper } from '@lume/app/note/components/wrapper';
|
import { NoteWrapper } from '@lume/app/note/components/wrapper';
|
||||||
@@ -45,8 +45,8 @@ export const MentionNote = memo(function MentionNote({ id }: { id: string }) {
|
|||||||
<>
|
<>
|
||||||
<NoteDefaultUser pubkey={data.pubkey} time={data.created_at} />
|
<NoteDefaultUser pubkey={data.pubkey} time={data.created_at} />
|
||||||
<div className="mt-1 pl-[46px]">
|
<div className="mt-1 pl-[46px]">
|
||||||
{kind1 && <NoteContent content={kind1} />}
|
{kind1 && <Kind1 content={kind1} />}
|
||||||
{kind1063 && <NoteFile url={kind1063[0][1]} />}
|
{kind1063 && <Kind1063 metadata={kind1063} />}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
) : (
|
) : (
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { NoteContent } from '@lume/app/note/components/content';
|
import { Kind1 } from '@lume/app/note/components/kind1';
|
||||||
import NoteFile from '@lume/app/note/components/file';
|
import { Kind1063 } from '@lume/app/note/components/kind1063';
|
||||||
import NoteMetadata from '@lume/app/note/components/metadata';
|
import NoteMetadata from '@lume/app/note/components/metadata';
|
||||||
import { NoteSkeleton } from '@lume/app/note/components/skeleton';
|
import { NoteSkeleton } from '@lume/app/note/components/skeleton';
|
||||||
import { NoteDefaultUser } from '@lume/app/note/components/user/default';
|
import { NoteDefaultUser } from '@lume/app/note/components/user/default';
|
||||||
@@ -46,8 +46,8 @@ export const NoteParent = memo(function NoteParent({ id }: { id: string }) {
|
|||||||
<>
|
<>
|
||||||
<NoteDefaultUser pubkey={data.pubkey} time={data.created_at} />
|
<NoteDefaultUser pubkey={data.pubkey} time={data.created_at} />
|
||||||
<div className="mt-3 pl-[46px]">
|
<div className="mt-3 pl-[46px]">
|
||||||
{kind1 && <NoteContent content={kind1} />}
|
{kind1 && <Kind1 content={kind1} />}
|
||||||
{kind1063 && <NoteFile url={kind1063[0][1]} />}
|
{kind1063 && <Kind1063 metadata={kind1063} />}
|
||||||
<NoteMetadata id={data.id} eventPubkey={data.pubkey} />
|
<NoteMetadata id={data.id} eventPubkey={data.pubkey} />
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
@@ -4,12 +4,7 @@ export default function ImagePreview({ urls }: { urls: string[] }) {
|
|||||||
return (
|
return (
|
||||||
<div className="mt-3 grid h-full w-full grid-cols-3">
|
<div className="mt-3 grid h-full w-full grid-cols-3">
|
||||||
<div className="col-span-3">
|
<div className="col-span-3">
|
||||||
<Image
|
<Image src={urls[0]} alt="image" className="h-auto w-full rounded-lg object-cover" />
|
||||||
src={urls[0]}
|
|
||||||
alt="image"
|
|
||||||
className="h-auto w-full rounded-lg object-cover"
|
|
||||||
style={{ contentVisibility: 'auto' }}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { NoteContent } from '@lume/app/note/components/content';
|
import { Kind1 } from '@lume/app/note/components/kind1';
|
||||||
import NoteReplyUser from '@lume/app/note/components/user/reply';
|
import NoteReplyUser from '@lume/app/note/components/user/reply';
|
||||||
import { noteParser } from '@lume/utils/parser';
|
import { noteParser } from '@lume/utils/parser';
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ export default function Reply({ data }: { data: any }) {
|
|||||||
<div className="flex flex-col">
|
<div className="flex flex-col">
|
||||||
<NoteReplyUser pubkey={data.pubkey} time={data.created_at} />
|
<NoteReplyUser pubkey={data.pubkey} time={data.created_at} />
|
||||||
<div className="-mt-[18px] pl-[46px]">
|
<div className="-mt-[18px] pl-[46px]">
|
||||||
<NoteContent content={content} />
|
<Kind1 content={content} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -17,7 +17,7 @@ export default function RepliesList({ id }: { id: string }) {
|
|||||||
{
|
{
|
||||||
'#e': [key],
|
'#e': [key],
|
||||||
since: 0,
|
since: 0,
|
||||||
kinds: [1],
|
kinds: [1, 1063],
|
||||||
limit: 20,
|
limit: 20,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { NoteContent } from '@lume/app/note/components/content';
|
import { Kind1 } from '@lume/app/note/components/kind1';
|
||||||
import NoteFile from '@lume/app/note/components/file';
|
import { Kind1063 } from '@lume/app/note/components/kind1063';
|
||||||
import NoteMetadata from '@lume/app/note/components/metadata';
|
import NoteMetadata from '@lume/app/note/components/metadata';
|
||||||
import { NoteSkeleton } from '@lume/app/note/components/skeleton';
|
import { NoteSkeleton } from '@lume/app/note/components/skeleton';
|
||||||
import { NoteDefaultUser } from '@lume/app/note/components/user/default';
|
import { NoteDefaultUser } from '@lume/app/note/components/user/default';
|
||||||
@@ -66,7 +66,7 @@ export const RootNote = memo(function RootNote({ id, fallback }: { id: string; f
|
|||||||
<div onClick={(e) => openNote(e)} className="flex flex-col px-3">
|
<div onClick={(e) => openNote(e)} className="flex flex-col px-3">
|
||||||
<NoteDefaultUser pubkey={parseFallback.pubkey} time={parseFallback.created_at} />
|
<NoteDefaultUser pubkey={parseFallback.pubkey} time={parseFallback.created_at} />
|
||||||
<div className="mt-3 pl-[46px]">
|
<div className="mt-3 pl-[46px]">
|
||||||
<NoteContent content={contentFallback} />
|
<Kind1 content={contentFallback} />
|
||||||
<NoteMetadata id={parseFallback.id} eventPubkey={parseFallback.pubkey} />
|
<NoteMetadata id={parseFallback.id} eventPubkey={parseFallback.pubkey} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -79,8 +79,8 @@ export const RootNote = memo(function RootNote({ id, fallback }: { id: string; f
|
|||||||
<>
|
<>
|
||||||
<NoteDefaultUser pubkey={data.pubkey} time={data.created_at} />
|
<NoteDefaultUser pubkey={data.pubkey} time={data.created_at} />
|
||||||
<div className="mt-3 pl-[46px]">
|
<div className="mt-3 pl-[46px]">
|
||||||
{kind1 && <NoteContent content={kind1} />}
|
{kind1 && <Kind1 content={kind1} />}
|
||||||
{kind1063 && <NoteFile url={kind1063[0][1]} />}
|
{kind1063 && <Kind1063 metadata={kind1063} />}
|
||||||
<NoteMetadata id={data.id} eventPubkey={data.pubkey} />
|
<NoteMetadata id={data.id} eventPubkey={data.pubkey} />
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
export const NoteSkeleton = () => {
|
export const NoteSkeleton = () => {
|
||||||
return (
|
return (
|
||||||
<div className="flex h-min flex-col">
|
<div className="flex h-min flex-col pb-3">
|
||||||
<div className="flex items-center gap-2.5">
|
<div className="flex items-center gap-2.5">
|
||||||
<div className="relative h-9 w-9 shrink overflow-hidden rounded-md bg-zinc-700" />
|
<div className="relative h-9 w-9 shrink overflow-hidden rounded-md bg-zinc-700" />
|
||||||
<div className="flex flex-col gap-0.5">
|
<div className="flex flex-col gap-0.5">
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { NoteContent } from '@lume/app/note/components/content';
|
import { Kind1 } from '@lume/app/note/components/kind1';
|
||||||
import NoteMetadata from '@lume/app/note/components/metadata';
|
import NoteMetadata from '@lume/app/note/components/metadata';
|
||||||
import RepliesList from '@lume/app/note/components/replies/list';
|
import RepliesList from '@lume/app/note/components/replies/list';
|
||||||
import { NoteDefaultUser } from '@lume/app/note/components/user/default';
|
import { NoteDefaultUser } from '@lume/app/note/components/user/default';
|
||||||
@@ -69,7 +69,7 @@ export function Page() {
|
|||||||
<div className="px-3 pt-3">
|
<div className="px-3 pt-3">
|
||||||
<NoteDefaultUser pubkey={data.pubkey} time={data.created_at} />
|
<NoteDefaultUser pubkey={data.pubkey} time={data.created_at} />
|
||||||
<div className="mt-3">
|
<div className="mt-3">
|
||||||
<NoteContent content={content} />
|
<Kind1 content={content} />
|
||||||
<NoteMetadata id={noteID} eventPubkey={data.pubkey} />
|
<NoteMetadata id={noteID} eventPubkey={data.pubkey} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -5,5 +5,7 @@ export const Image = (props) => {
|
|||||||
event.currentTarget.src = DEFAULT_AVATAR;
|
event.currentTarget.src = DEFAULT_AVATAR;
|
||||||
};
|
};
|
||||||
|
|
||||||
return <img {...props} loading="lazy" decoding="async" onError={addImageFallback} />;
|
return (
|
||||||
|
<img {...props} loading="lazy" decoding="async" onError={addImageFallback} style={{ contentVisibility: 'auto' }} />
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
@@ -93,7 +93,7 @@ export async function getNotes(time: number, limit: number, offset: number) {
|
|||||||
|
|
||||||
const notes: any = { data: null, nextCursor: 0 };
|
const notes: any = { data: null, nextCursor: 0 };
|
||||||
const query: any = await db.select(
|
const query: any = await db.select(
|
||||||
`SELECT * FROM notes WHERE created_at <= "${time}" AND kind IN (1, 6) GROUP BY parent_id ORDER BY created_at DESC LIMIT "${limit}" OFFSET "${offset}";`
|
`SELECT * FROM notes WHERE created_at <= "${time}" AND kind IN (1, 6, 1063) GROUP BY parent_id ORDER BY created_at DESC LIMIT "${limit}" OFFSET "${offset}";`
|
||||||
);
|
);
|
||||||
|
|
||||||
notes['data'] = query;
|
notes['data'] = query;
|
||||||
|
Reference in New Issue
Block a user