restructure note component

This commit is contained in:
Ren Amamiya
2023-06-20 09:01:48 +07:00
parent aa8531b32b
commit 9b84068e6d
22 changed files with 257 additions and 286 deletions

View File

@@ -1,7 +1,6 @@
import { getNotesByAuthor } from "@libs/storage";
import { CancelIcon } from "@shared/icons";
import { NoteBase } from "@shared/notes/base";
import { NoteQuoteRepost } from "@shared/notes/quoteRepost";
import { Note } from "@shared/notes/note";
import { NoteSkeleton } from "@shared/notes/skeleton";
import { useActiveAccount } from "@stores/accounts";
import { useVirtualizer } from "@tanstack/react-virtual";
@@ -101,35 +100,15 @@ export function FeedBlock({ params }: { params: any }) {
{rowVirtualizer.getVirtualItems().map((virtualRow) => {
const note = notes[virtualRow.index];
if (note) {
if (note.kind === 1) {
return (
<div
key={virtualRow.index}
data-index={virtualRow.index}
ref={rowVirtualizer.measureElement}
>
<NoteBase
key={note.event_id}
block={params.id}
event={note}
/>
</div>
);
} else {
return (
<div
key={virtualRow.index}
data-index={virtualRow.index}
ref={rowVirtualizer.measureElement}
>
<NoteQuoteRepost
key={note.event_id}
block={params.id}
event={note}
/>
</div>
);
}
return (
<div
key={virtualRow.index}
data-index={virtualRow.index}
ref={rowVirtualizer.measureElement}
>
<Note event={note} block={params.id} />
</div>
);
}
})}
</div>

View File

@@ -1,7 +1,6 @@
import { createNote, getNotes } from "@libs/storage";
import { NDKEvent } from "@nostr-dev-kit/ndk";
import { NoteBase } from "@shared/notes/base";
import { NoteQuoteRepost } from "@shared/notes/quoteRepost";
import { Note } from "@shared/notes/note";
import { NoteSkeleton } from "@shared/notes/skeleton";
import { RelayContext } from "@shared/relayProvider";
import { useActiveAccount } from "@stores/accounts";
@@ -86,20 +85,11 @@ export function FollowingBlock({ block }: { block: number }) {
const note = notes[index];
if (!note) return;
if (note.kind === 1) {
return (
<div key={index} data-index={index} ref={rowVirtualizer.measureElement}>
<NoteBase block={block} event={note} />
</div>
);
} else {
return (
<div key={index} data-index={index} ref={rowVirtualizer.measureElement}>
<NoteQuoteRepost block={block} event={note} />
</div>
);
}
return (
<div key={index} data-index={index} ref={rowVirtualizer.measureElement}>
<Note event={note} block={block} />
</div>
);
};
return (

View File

@@ -1,7 +1,7 @@
import { getNoteByID } from "@libs/storage";
import { ArrowLeftIcon } from "@shared/icons";
import { Kind1 } from "@shared/notes/kind1";
import { Kind1063 } from "@shared/notes/kind1063";
import { Kind1 } from "@shared/notes/contents/kind1";
import { Kind1063 } from "@shared/notes/contents/kind1063";
import { NoteMetadata } from "@shared/notes/metadata";
import { NoteReplyForm } from "@shared/notes/replies/form";
import { RepliesList } from "@shared/notes/replies/list";