-
+
{data.content}
diff --git a/src/app/relays/components/relayEventList.tsx b/src/app/relays/components/relayEventList.tsx
index 399e1666..12c764eb 100644
--- a/src/app/relays/components/relayEventList.tsx
+++ b/src/app/relays/components/relayEventList.tsx
@@ -6,14 +6,7 @@ import { VList } from 'virtua';
import { useNDK } from '@libs/ndk/provider';
import { LoaderIcon } from '@shared/icons';
-import {
- ArticleNote,
- FileNote,
- NoteWrapper,
- Repost,
- TextNote,
- UnknownNote,
-} from '@shared/notes';
+import { MemoizedRepost, MemoizedTextNote, UnknownNote } from '@shared/notes';
export function RelayEventList({ relayUrl }: { relayUrl: string }) {
const { fetcher } = useNDK();
@@ -24,9 +17,9 @@ export function RelayEventList({ relayUrl }: { relayUrl: string }) {
const events = await fetcher.fetchLatestEvents(
[url],
{
- kinds: [NDKKind.Text, NDKKind.Repost, 1063, NDKKind.Article],
+ kinds: [NDKKind.Text, NDKKind.Repost],
},
- 100
+ 20
);
return events as unknown as NDKEvent[];
},
@@ -37,31 +30,11 @@ export function RelayEventList({ relayUrl }: { relayUrl: string }) {
(event: NDKEvent) => {
switch (event.kind) {
case NDKKind.Text:
- return (
-
-
-
- );
+ return
;
case NDKKind.Repost:
- return
;
- case 1063:
- return (
-
-
-
- );
- case NDKKind.Article:
- return (
-
-
-
- );
+ return
;
default:
- return (
-
-
-
- );
+ return
;
}
},
[data]
diff --git a/src/app/users/index.tsx b/src/app/users/index.tsx
index bcad621b..f34c57cf 100644
--- a/src/app/users/index.tsx
+++ b/src/app/users/index.tsx
@@ -7,14 +7,7 @@ import { UserProfile } from '@app/users/components/profile';
import { useNDK } from '@libs/ndk/provider';
-import {
- ArticleNote,
- FileNote,
- NoteWrapper,
- Repost,
- TextNote,
- UnknownNote,
-} from '@shared/notes';
+import { MemoizedRepost, MemoizedTextNote, UnknownNote } from '@shared/notes';
export function UserScreen() {
const { pubkey } = useParams();
@@ -23,9 +16,9 @@ export function UserScreen() {
queryKey: ['user-feed', pubkey],
queryFn: async () => {
const events = await ndk.fetchEvents({
- kinds: [NDKKind.Text, NDKKind.Repost, NDKKind.Article],
+ kinds: [NDKKind.Text, NDKKind.Repost],
authors: [pubkey],
- limit: 50,
+ limit: 20,
});
const sorted = [...events].sort((a, b) => b.created_at - a.created_at);
return sorted;
@@ -38,31 +31,11 @@ export function UserScreen() {
(event: NDKEvent) => {
switch (event.kind) {
case NDKKind.Text:
- return (
-
-
-
- );
+ return
;
case NDKKind.Repost:
- return
;
- case 1063:
- return (
-
-
-
- );
- case NDKKind.Article:
- return (
-
-
-
- );
+ return
;
default:
- return (
-
-
-
- );
+ return
;
}
},
[data]
diff --git a/src/libs/ndk/instance.ts b/src/libs/ndk/instance.ts
index 5a0028b4..dfc0737e 100644
--- a/src/libs/ndk/instance.ts
+++ b/src/libs/ndk/instance.ts
@@ -77,10 +77,10 @@ export const NDKInstance = () => {
const outboxSetting = await db.getSettingValue('outbox');
const explicitRelayUrls = await getExplicitRelays();
- const dexieAdapter = new NDKCacheAdapterTauri(db);
+ const tauriAdapter = new NDKCacheAdapterTauri(db);
const instance = new NDK({
explicitRelayUrls,
- cacheAdapter: dexieAdapter,
+ cacheAdapter: tauriAdapter,
outboxRelayUrls: ['wss://purplepag.es'],
enableOutboxModel: outboxSetting === '1',
});
diff --git a/src/main.jsx b/src/main.jsx
index 39f2d8f1..6cd4518b 100644
--- a/src/main.jsx
+++ b/src/main.jsx
@@ -1,6 +1,4 @@
-import { createSyncStoragePersister } from '@tanstack/query-sync-storage-persister';
-import { QueryClient } from '@tanstack/react-query';
-import { PersistQueryClientProvider } from '@tanstack/react-query-persist-client';
+import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { createRoot } from 'react-dom/client';
import { Toaster } from 'sonner';
@@ -17,31 +15,16 @@ const queryClient = new QueryClient({
},
});
-const persister = createSyncStoragePersister({
- storage: window.localStorage,
-});
-
const container = document.getElementById('root');
const root = createRoot(container);
root.render(
-
{
- if (query.queryKey === 'widgets') return false;
- return true;
- },
- },
- }}
- >
+
-
+
);
diff --git a/src/shared/notes/actions.tsx b/src/shared/notes/actions.tsx
index 2c399257..17a1f148 100644
--- a/src/shared/notes/actions.tsx
+++ b/src/shared/notes/actions.tsx
@@ -25,15 +25,9 @@ export function NoteActions({
return (
-
-
-
-
-
-
-
+
{extraButtons && (
-
+
@@ -59,6 +54,12 @@ export function NoteActions({
)}
+
+
+
+
+
+
);
diff --git a/src/shared/notes/article.tsx b/src/shared/notes/article.tsx
new file mode 100644
index 00000000..56d16760
--- /dev/null
+++ b/src/shared/notes/article.tsx
@@ -0,0 +1,72 @@
+import { NDKEvent } from '@nostr-dev-kit/ndk';
+import { memo } from 'react';
+import { Link } from 'react-router-dom';
+
+import { User } from '@shared/user';
+
+import { NoteActions } from './actions';
+
+export function ArticleNote({ event }: { event: NDKEvent }) {
+ const getMetadata = () => {
+ const title = event.tags.find((tag) => tag[0] === 'title')?.[1];
+ const image = event.tags.find((tag) => tag[0] === 'image')?.[1];
+ const summary = event.tags.find((tag) => tag[0] === 'summary')?.[1];
+
+ let publishedAt: Date | string | number = event.tags.find(
+ (tag) => tag[0] === 'published_at'
+ )?.[1];
+ if (publishedAt) {
+ publishedAt = new Date(parseInt(publishedAt) * 1000).toLocaleDateString('en-US');
+ } else {
+ publishedAt = new Date(event.created_at * 1000).toLocaleDateString('en-US');
+ }
+
+ return {
+ title,
+ image,
+ publishedAt,
+ summary,
+ };
+ };
+
+ const metadata = getMetadata();
+
+ return (
+
+
+
+
+
+ {metadata.image && (
+
+ )}
+
+
+ {metadata.title}
+
+ {metadata.summary ? (
+
+ {metadata.summary}
+
+ ) : null}
+
+ {metadata.publishedAt.toString()}
+
+
+
+
+
+
+
+ );
+}
+
+export const MemoizedArticleNote = memo(ArticleNote);
diff --git a/src/shared/notes/child.tsx b/src/shared/notes/child.tsx
index 0937a08a..5cf63e8a 100644
--- a/src/shared/notes/child.tsx
+++ b/src/shared/notes/child.tsx
@@ -1,90 +1,29 @@
-import { NDKEvent, NDKKind } from '@nostr-dev-kit/ndk';
-import { nip19 } from 'nostr-tools';
-import { useCallback } from 'react';
-
-import {
- ArticleNote,
- FileNote,
- LinkPreview,
- NoteActions,
- NoteSkeleton,
- TextNote,
- UnknownNote,
-} from '@shared/notes';
+import { NoteSkeleton } from '@shared/notes';
import { User } from '@shared/user';
import { useEvent } from '@utils/hooks/useEvent';
-export function ChildNote({ id, root }: { id: string; root?: string }) {
+export function ChildNote({ id, isRoot }: { id: string; isRoot?: boolean }) {
const { status, data } = useEvent(id);
- const renderKind = useCallback(
- (event: NDKEvent) => {
- switch (event.kind) {
- case NDKKind.Text:
- return
;
- case NDKKind.Article:
- return
;
- case 1063:
- return
;
- default:
- return
;
- }
- },
- [id]
- );
-
if (status === 'pending') {
- return (
- <>
-
-
-
-
- >
- );
- }
-
- if (status === 'error') {
- const noteLink = `https://njump.me/${nip19.noteEncode(id)}`;
- return (
- <>
-
-
-
-
-
-
-
- Lume cannot find this post with your current relay set, but you can view
- it via njump.me
-
-
-
-
-
- >
- );
+ return
;
}
return (
- <>
-
-
-
-
-
-
- {renderKind(data)}
-
-
+
);
}
diff --git a/src/shared/notes/file.tsx b/src/shared/notes/file.tsx
new file mode 100644
index 00000000..1792b906
--- /dev/null
+++ b/src/shared/notes/file.tsx
@@ -0,0 +1,93 @@
+import { NDKEvent } from '@nostr-dev-kit/ndk';
+import { downloadDir } from '@tauri-apps/api/path';
+import { download } from '@tauri-apps/plugin-upload';
+import {
+ MediaControlBar,
+ MediaController,
+ MediaFullscreenButton,
+ MediaMuteButton,
+ MediaPlayButton,
+ MediaTimeRange,
+} from 'media-chrome/dist/react';
+import { memo } from 'react';
+import { Link } from 'react-router-dom';
+
+import { DownloadIcon } from '@shared/icons';
+import { NoteActions } from '@shared/notes';
+import { User } from '@shared/user';
+
+import { fileType } from '@utils/nip94';
+
+export function FileNote({ event }: { event: NDKEvent }) {
+ const downloadImage = async (url: string) => {
+ const downloadDirPath = await downloadDir();
+ const filename = url.substring(url.lastIndexOf('/') + 1);
+ return await download(url, downloadDirPath + `/${filename}`);
+ };
+
+ const renderFileType = () => {
+ const url = event.tags.find((el) => el[0] === 'url')[1];
+ const type = fileType(url);
+
+ switch (type) {
+ case 'image':
+ return (
+
+
+
+
+ );
+ case 'video':
+ return (
+
+
+
+
+
+
+
+
+
+ );
+ default:
+ return (
+
+ {url}
+
+ );
+ }
+ };
+
+ return (
+
+
+
+
{renderFileType()}
+
+
+
+ );
+}
+
+export const MemoizedFileNote = memo(FileNote);
diff --git a/src/shared/notes/index.ts b/src/shared/notes/index.ts
index a9018ac7..83e74953 100644
--- a/src/shared/notes/index.ts
+++ b/src/shared/notes/index.ts
@@ -1,9 +1,18 @@
+export * from './text';
+export * from './repost';
+export * from './file';
+export * from './article';
+export * from './child';
+export * from './notify';
+export * from './unknown';
+export * from './skeleton';
+export * from './stats';
+export * from './actions';
export * from './actions/reaction';
export * from './actions/reply';
export * from './actions/repost';
export * from './actions/zap';
-export * from './mentions/note';
-export * from './mentions/user';
+export * from './actions/more';
export * from './preview/image';
export * from './preview/link';
export * from './preview/video';
@@ -11,20 +20,11 @@ export * from './replies/form';
export * from './replies/item';
export * from './replies/list';
export * from './replies/sub';
-export * from './kinds/text';
-export * from './kinds/file';
-export * from './kinds/article';
-export * from './kinds/articleDetail';
-export * from './kinds/unknown';
-export * from './metadata';
-export * from './kinds/repost';
-export * from './child';
-export * from './skeleton';
-export * from './actions';
-export * from './mentions/hashtag';
-export * from './mentions/boost';
-export * from './mentions/invoice';
-export * from './stats';
-export * from './wrapper';
-export * from './actions/more';
export * from './replies/replyMediaUploader';
+export * from './mentions/note';
+export * from './mentions/user';
+export * from './mentions/hashtag';
+export * from './mentions/invoice';
+export * from './kinds/text';
+export * from './kinds/article';
+export * from './kinds/file';
diff --git a/src/shared/notes/kinds/article.tsx b/src/shared/notes/kinds/article.tsx
index 4f62ea5e..6417d40c 100644
--- a/src/shared/notes/kinds/article.tsx
+++ b/src/shared/notes/kinds/article.tsx
@@ -1,21 +1,18 @@
-import { NDKEvent } from '@nostr-dev-kit/ndk';
-import { memo, useMemo } from 'react';
+import { NDKTag } from '@nostr-dev-kit/ndk';
+import { memo } from 'react';
import { Link } from 'react-router-dom';
-export function ArticleNote(props: { event?: NDKEvent }) {
- const metadata = useMemo(() => {
- const title = props.event.tags.find((tag) => tag[0] === 'title')?.[1];
- const image = props.event.tags.find((tag) => tag[0] === 'image')?.[1];
- const summary = props.event.tags.find((tag) => tag[0] === 'summary')?.[1];
+export function ArticleKind({ id, tags }: { id: string; tags: NDKTag[] }) {
+ const getMetadata = () => {
+ const title = tags.find((tag) => tag[0] === 'title')?.[1];
+ const image = tags.find((tag) => tag[0] === 'image')?.[1];
+ const summary = tags.find((tag) => tag[0] === 'summary')?.[1];
- let publishedAt: Date | string | number = props.event.tags.find(
+ let publishedAt: Date | string | number = tags.find(
(tag) => tag[0] === 'published_at'
)?.[1];
- if (publishedAt) {
- publishedAt = new Date(parseInt(publishedAt) * 1000).toLocaleDateString('en-US');
- } else {
- publishedAt = new Date(props.event.created_at * 1000).toLocaleDateString('en-US');
- }
+
+ publishedAt = new Date(parseInt(publishedAt) * 1000).toLocaleDateString('en-US');
return {
title,
@@ -23,23 +20,25 @@ export function ArticleNote(props: { event?: NDKEvent }) {
publishedAt,
summary,
};
- }, [props.event.id]);
+ };
+
+ const metadata = getMetadata();
return (
{metadata.image && (
)}
-
+
{metadata.title}
{metadata.summary ? (
@@ -55,4 +54,4 @@ export function ArticleNote(props: { event?: NDKEvent }) {
);
}
-export const MemoizedArticleNote = memo(ArticleNote);
+export const MemoizedArticleKind = memo(ArticleKind);
diff --git a/src/shared/notes/kinds/articleDetail.tsx b/src/shared/notes/kinds/articleDetail.tsx
deleted file mode 100644
index 4fc5f6b6..00000000
--- a/src/shared/notes/kinds/articleDetail.tsx
+++ /dev/null
@@ -1,38 +0,0 @@
-import { NDKEvent } from '@nostr-dev-kit/ndk';
-import Markdown from 'markdown-to-jsx';
-
-import { Boost, Hashtag, Invoice, MentionUser } from '@shared/notes';
-
-export function ArticleDetailNote({ event }: { event: NDKEvent }) {
- return (
- str,
- forceBlock: true,
- enforceAtxHeadings: true,
- }}
- className="break-p prose prose-neutral max-w-none select-text whitespace-pre-line leading-normal dark:prose-invert prose-headings:mb-1 prose-headings:mt-3 prose-p:mb-0 prose-p:mt-0 prose-p:last:mb-1 prose-a:font-normal prose-a:text-blue-500 prose-blockquote:mb-1 prose-blockquote:mt-1 prose-blockquote:border-l-[2px] prose-blockquote:border-blue-500 prose-blockquote:pl-2 prose-pre:whitespace-pre-wrap prose-pre:bg-white/10 prose-ol:m-0 prose-ol:mb-1 prose-ul:mb-1 prose-ul:mt-1 prose-img:mb-2 prose-img:mt-3 prose-hr:mx-0 prose-hr:my-2 hover:prose-a:text-blue-500"
- >
- {event.content}
-
- );
-}
diff --git a/src/shared/notes/kinds/file.tsx b/src/shared/notes/kinds/file.tsx
index 38fb833b..326b6383 100644
--- a/src/shared/notes/kinds/file.tsx
+++ b/src/shared/notes/kinds/file.tsx
@@ -1,4 +1,4 @@
-import { NDKEvent } from '@nostr-dev-kit/ndk';
+import { NDKTag } from '@nostr-dev-kit/ndk';
import { downloadDir } from '@tauri-apps/api/path';
import { download } from '@tauri-apps/plugin-upload';
import {
@@ -10,14 +10,14 @@ import {
MediaTimeRange,
} from 'media-chrome/dist/react';
import { memo } from 'react';
+import { Link } from 'react-router-dom';
import { DownloadIcon } from '@shared/icons';
-import { LinkPreview } from '@shared/notes';
import { fileType } from '@utils/nip94';
-export function FileNote(props: { event?: NDKEvent }) {
- const url = props.event.tags.find((el) => el[0] === 'url')[1];
+export function FileKind({ tags }: { tags: NDKTag[] }) {
+ const url = tags.find((el) => el[0] === 'url')[1];
const type = fileType(url);
const downloadImage = async (url: string) => {
@@ -28,11 +28,14 @@ export function FileNote(props: { event?: NDKEvent }) {
if (type === 'image') {
return (
-
+