diff --git a/src/app/inital-data/pages/index.page.tsx b/src/app/inital-data/pages/index.page.tsx index 98f71802..0a4ba408 100644 --- a/src/app/inital-data/pages/index.page.tsx +++ b/src/app/inital-data/pages/index.page.tsx @@ -59,7 +59,7 @@ export function Page() { // kind 1 (notes) query query.push({ - kinds: [1, 6], + kinds: [1, 6, 1063], authors: follows, since: sinceNotes, until: dateToUnix(now.current), @@ -140,6 +140,18 @@ export function Page() { addToBlacklist(account.id, event.tags[0][1], 44, 1); } break; + case 1063: + createNote( + event.id, + account.id, + event.pubkey, + event.kind, + event.tags, + event.content, + event.created_at, + '' + ); + break; // long post case 30023: // insert event to local database diff --git a/src/app/note/components/base.tsx b/src/app/note/components/base.tsx index 0fb6ae6c..7a61f63d 100644 --- a/src/app/note/components/base.tsx +++ b/src/app/note/components/base.tsx @@ -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 { NoteParent } from '@lume/app/note/components/parent'; import { NoteDefaultUser } from '@lume/app/note/components/user/default'; @@ -25,7 +26,8 @@ export const NoteBase = ({ event }: { event: any }) => {
- + {event.kind === 1 && } + {event.kind === 1063 && }
diff --git a/src/app/note/components/file.tsx b/src/app/note/components/file.tsx deleted file mode 100644 index 14bf7afe..00000000 --- a/src/app/note/components/file.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import { Image } from '@lume/shared/image'; - -export default function NoteFile({ url }: { url: string }) { - return ( -
-
- image -
-
- ); -} diff --git a/src/app/note/components/content.tsx b/src/app/note/components/kind1.tsx similarity index 91% rename from src/app/note/components/content.tsx rename to src/app/note/components/kind1.tsx index 61714f88..d6e7659d 100644 --- a/src/app/note/components/content.tsx +++ b/src/app/note/components/kind1.tsx @@ -6,7 +6,7 @@ import VideoPreview from '@lume/app/note/components/preview/video'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; -export const NoteContent = ({ content }: { content: any }) => { +export const Kind1 = ({ content }: { content: any }) => { return ( <> { {Array.isArray(content.images) && content.images.length ? : <>} {Array.isArray(content.videos) && content.videos.length ? : <>} - {!Array.isArray(content.notes) && !content.notes.length ? ( - <> - ) : ( + {Array.isArray(content.notes) && content.notes.length ? ( content.notes.map((note: string) => ) + ) : ( + <> )} ); diff --git a/src/app/note/components/kind1063.tsx b/src/app/note/components/kind1063.tsx new file mode 100644 index 00000000..93e16cd2 --- /dev/null +++ b/src/app/note/components/kind1063.tsx @@ -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 ( +
+ {isImage(url) && image} +
+ ); +}; diff --git a/src/app/note/components/mentions/note.tsx b/src/app/note/components/mentions/note.tsx index 570bf5f4..df548c7c 100644 --- a/src/app/note/components/mentions/note.tsx +++ b/src/app/note/components/mentions/note.tsx @@ -1,5 +1,5 @@ -import { NoteContent } from '@lume/app/note/components/content'; -import NoteFile from '@lume/app/note/components/file'; +import { Kind1 } from '@lume/app/note/components/kind1'; +import { Kind1063 } from '@lume/app/note/components/kind1063'; import { NoteSkeleton } from '@lume/app/note/components/skeleton'; import { NoteDefaultUser } from '@lume/app/note/components/user/default'; import { NoteWrapper } from '@lume/app/note/components/wrapper'; @@ -45,8 +45,8 @@ export const MentionNote = memo(function MentionNote({ id }: { id: string }) { <>
- {kind1 && } - {kind1063 && } + {kind1 && } + {kind1063 && }
) : ( diff --git a/src/app/note/components/parent.tsx b/src/app/note/components/parent.tsx index f930ec74..91219c0e 100644 --- a/src/app/note/components/parent.tsx +++ b/src/app/note/components/parent.tsx @@ -1,5 +1,5 @@ -import { NoteContent } from '@lume/app/note/components/content'; -import NoteFile from '@lume/app/note/components/file'; +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 { NoteSkeleton } from '@lume/app/note/components/skeleton'; import { NoteDefaultUser } from '@lume/app/note/components/user/default'; @@ -46,8 +46,8 @@ export const NoteParent = memo(function NoteParent({ id }: { id: string }) { <>
- {kind1 && } - {kind1063 && } + {kind1 && } + {kind1063 && }
diff --git a/src/app/note/components/preview/image.tsx b/src/app/note/components/preview/image.tsx index 7a03c5fa..34c78081 100644 --- a/src/app/note/components/preview/image.tsx +++ b/src/app/note/components/preview/image.tsx @@ -4,12 +4,7 @@ export default function ImagePreview({ urls }: { urls: string[] }) { return (
- image + image
); diff --git a/src/app/note/components/replies/item.tsx b/src/app/note/components/replies/item.tsx index 0a557643..83bb549f 100644 --- a/src/app/note/components/replies/item.tsx +++ b/src/app/note/components/replies/item.tsx @@ -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 { noteParser } from '@lume/utils/parser'; @@ -10,7 +10,7 @@ export default function Reply({ data }: { data: any }) {
- +
diff --git a/src/app/note/components/replies/list.tsx b/src/app/note/components/replies/list.tsx index 6bd25681..e00f54ff 100644 --- a/src/app/note/components/replies/list.tsx +++ b/src/app/note/components/replies/list.tsx @@ -17,7 +17,7 @@ export default function RepliesList({ id }: { id: string }) { { '#e': [key], since: 0, - kinds: [1], + kinds: [1, 1063], limit: 20, }, ], diff --git a/src/app/note/components/rootNote.tsx b/src/app/note/components/rootNote.tsx index 7894a183..28835963 100644 --- a/src/app/note/components/rootNote.tsx +++ b/src/app/note/components/rootNote.tsx @@ -1,5 +1,5 @@ -import { NoteContent } from '@lume/app/note/components/content'; -import NoteFile from '@lume/app/note/components/file'; +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 { NoteSkeleton } from '@lume/app/note/components/skeleton'; import { NoteDefaultUser } from '@lume/app/note/components/user/default'; @@ -66,7 +66,7 @@ export const RootNote = memo(function RootNote({ id, fallback }: { id: string; f
openNote(e)} className="flex flex-col px-3">
- +
@@ -79,8 +79,8 @@ export const RootNote = memo(function RootNote({ id, fallback }: { id: string; f <>
- {kind1 && } - {kind1063 && } + {kind1 && } + {kind1063 && }
diff --git a/src/app/note/components/skeleton.tsx b/src/app/note/components/skeleton.tsx index 16ab45d4..9540364a 100644 --- a/src/app/note/components/skeleton.tsx +++ b/src/app/note/components/skeleton.tsx @@ -1,6 +1,6 @@ export const NoteSkeleton = () => { return ( -
+
diff --git a/src/app/note/pages/index.page.tsx b/src/app/note/pages/index.page.tsx index c75cf465..7e89034e 100644 --- a/src/app/note/pages/index.page.tsx +++ b/src/app/note/pages/index.page.tsx @@ -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 RepliesList from '@lume/app/note/components/replies/list'; import { NoteDefaultUser } from '@lume/app/note/components/user/default'; @@ -69,7 +69,7 @@ export function Page() {
- +
diff --git a/src/shared/image.tsx b/src/shared/image.tsx index f50e8e41..8da699f5 100644 --- a/src/shared/image.tsx +++ b/src/shared/image.tsx @@ -5,5 +5,7 @@ export const Image = (props) => { event.currentTarget.src = DEFAULT_AVATAR; }; - return ; + return ( + + ); }; diff --git a/src/utils/storage.tsx b/src/utils/storage.tsx index ad1ec394..0520c244 100644 --- a/src/utils/storage.tsx +++ b/src/utils/storage.tsx @@ -93,7 +93,7 @@ export async function getNotes(time: number, limit: number, offset: number) { const notes: any = { data: null, nextCursor: 0 }; 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;