diff --git a/src/shared/notes/content.tsx b/src/shared/notes/content.tsx
new file mode 100644
index 00000000..a3c4c0ea
--- /dev/null
+++ b/src/shared/notes/content.tsx
@@ -0,0 +1,54 @@
+import ReactMarkdown from 'react-markdown';
+import remarkGfm from 'remark-gfm';
+
+import {
+ ImagePreview,
+ LinkPreview,
+ MentionNote,
+ MentionUser,
+ VideoPreview,
+} from '@shared/notes';
+
+export function NoteContent({
+ content,
+}: {
+ content: {
+ original: string;
+ parsed: string;
+ notes: string[];
+ images: string[];
+ videos: string[];
+ links: string[];
+ };
+}) {
+ return (
+ <>
+ {
+ const key = children[0] as string;
+ if (key.startsWith('pub')) return ;
+ if (key.startsWith('tag'))
+ return (
+
+ );
+ },
+ }}
+ >
+ {content.parsed}
+
+ {content.images.length > 0 && }
+ {content.videos.length > 0 && }
+ {content.links.length > 0 && }
+ {content.notes.length > 0 &&
+ content.notes.map((note: string) => )}
+ >
+ );
+}
diff --git a/src/shared/notes/index.tsx b/src/shared/notes/index.tsx
index de14f037..b12f5be9 100644
--- a/src/shared/notes/index.tsx
+++ b/src/shared/notes/index.tsx
@@ -20,3 +20,4 @@ export * from './kinds/repost';
export * from './kinds/sub';
export * from './skeleton';
export * from './actions';
+export * from './content';
diff --git a/src/shared/notes/kinds/kind1.tsx b/src/shared/notes/kinds/kind1.tsx
index 34b3d702..3cfa7562 100644
--- a/src/shared/notes/kinds/kind1.tsx
+++ b/src/shared/notes/kinds/kind1.tsx
@@ -1,16 +1,6 @@
import { useMemo } from 'react';
-import ReactMarkdown from 'react-markdown';
-import remarkGfm from 'remark-gfm';
-import {
- LinkPreview,
- MentionUser,
- NoteActions,
- NoteMetadata,
- VideoPreview,
-} from '@shared/notes';
-import { MentionNote } from '@shared/notes/mentions/note';
-import { ImagePreview } from '@shared/notes/preview/image';
+import { NoteActions, NoteContent, NoteMetadata } from '@shared/notes';
import { User } from '@shared/user';
import { parser } from '@utils/parser';
@@ -30,36 +20,10 @@ export function NoteKind_1({
-
+
-
{
- const key = children[0] as string;
- if (key.startsWith('pub'))
- return ;
- if (key.startsWith('tag'))
- return (
-
- );
- },
- }}
- >
- {content.parsed}
-
- {content.images.length > 0 &&
}
- {content.videos.length > 0 &&
}
- {content.links.length > 0 &&
}
- {content.notes.length > 0 &&
- content.notes.map((note: string) =>
)}
+
-
+
{isImage(url) && (
diff --git a/src/shared/notes/kinds/repost.tsx b/src/shared/notes/kinds/repost.tsx
index b1705514..7ab7ff16 100644
--- a/src/shared/notes/kinds/repost.tsx
+++ b/src/shared/notes/kinds/repost.tsx
@@ -1,16 +1,9 @@
-import ReactMarkdown from 'react-markdown';
-import remarkGfm from 'remark-gfm';
-
import {
- ImagePreview,
- LinkPreview,
- MentionNote,
- MentionUser,
NoteActions,
+ NoteContent,
NoteMetadata,
NoteSkeleton,
RepostUser,
- VideoPreview,
} from '@shared/notes';
import { User } from '@shared/user';
@@ -49,29 +42,7 @@ export function Repost({ event }: { event: LumeEvent }) {
-
{
- const pubkey = children[0] as string;
- return ;
- },
- }}
- >
- {data.content.parsed}
-
- {data.content.images.length > 0 && (
-
- )}
- {data.content.videos.length > 0 && (
-
- )}
- {data.content.links.length > 0 &&
}
- {data.content.notes.length > 0 &&
- data.content.notes.map((note: string) => (
-
- ))}
+
-
+
- {
- const pubkey = children[0] as string;
- return ;
- },
- }}
- >
- {data.content.parsed}
-
- {data.content.images.length > 0 && (
-
- )}
- {data.content.videos.length > 0 && (
-
- )}
- {data.content.links.length > 0 && }
- {data.content.notes.length > 0 &&
- data.content.notes.map((note: string) => (
-
- ))}
+
diff --git a/src/shared/notes/kinds/thread.tsx b/src/shared/notes/kinds/thread.tsx
index 82fc4add..5a6fd43a 100644
--- a/src/shared/notes/kinds/thread.tsx
+++ b/src/shared/notes/kinds/thread.tsx
@@ -1,17 +1,6 @@
import { useMemo } from 'react';
-import ReactMarkdown from 'react-markdown';
-import remarkGfm from 'remark-gfm';
-import {
- LinkPreview,
- MentionUser,
- NoteActions,
- NoteMetadata,
- SubNote,
- VideoPreview,
-} from '@shared/notes';
-import { MentionNote } from '@shared/notes/mentions/note';
-import { ImagePreview } from '@shared/notes/preview/image';
+import { NoteActions, NoteContent, NoteMetadata, SubNote } from '@shared/notes';
import { User } from '@shared/user';
import { parser } from '@utils/parser';
@@ -35,26 +24,10 @@ export function NoteThread({
{reply && }
-
+
- {
- const pubkey = children[0] as string;
- return ;
- },
- }}
- >
- {content.parsed}
-
- {content.images.length > 0 && }
- {content.videos.length > 0 && }
- {content.links.length > 0 && }
- {content.notes.length > 0 &&
- content.notes.map((note: string) => )}
+
{
- const pubkey = children[0] as string;
- return ;
+ const key = children[0] as string;
+ if (key.startsWith('pub')) return ;
+ if (key.startsWith('tag'))
+ return (
+
+ );
},
}}
>
diff --git a/src/shared/notes/mentions/user.tsx b/src/shared/notes/mentions/user.tsx
index 20bef718..49fcf80f 100644
--- a/src/shared/notes/mentions/user.tsx
+++ b/src/shared/notes/mentions/user.tsx
@@ -1,5 +1,3 @@
-import { Link } from 'react-router-dom';
-
import { useProfile } from '@utils/hooks/useProfile';
import { shortenKey } from '@utils/shortenKey';
@@ -7,11 +5,11 @@ export function MentionUser({ pubkey }: { pubkey: string }) {
const { user } = useProfile(pubkey);
return (
-
@{user?.name || user?.displayName || shortenKey(pubkey)}
-
+
);
}
diff --git a/src/utils/parser.tsx b/src/utils/parser.tsx
index 2c9c18ec..de84283f 100644
--- a/src/utils/parser.tsx
+++ b/src/utils/parser.tsx
@@ -1,9 +1,6 @@
import getUrls from 'get-urls';
import { Event, parseReferences } from 'nostr-tools';
-import { Link } from 'react-router-dom';
-import reactStringReplace from 'react-string-replace';
-
-import { MentionUser } from '@shared/notes/mentions/user';
+import ReactPlayer from 'react-player';
import { LumeEvent } from '@utils/types';
@@ -34,7 +31,7 @@ export function parser(event: LumeEvent) {
content.images.push(url);
// remove url from original content
content.parsed = content.parsed.replace(url, '');
- } else if (url.match(/\.(mp4|webm|mov|ogv|avi|mp3)$/)) {
+ } else if (ReactPlayer.canPlay(url)) {
// video
content.videos.push(url);
// remove url from original content