diff --git a/src/app/note/components/base.tsx b/src/app/note/components/base.tsx index a2b2e19c..ea814a27 100644 --- a/src/app/note/components/base.tsx +++ b/src/app/note/components/base.tsx @@ -20,7 +20,7 @@ export function NoteBase({ event }: { event: any }) { return ( -
+
{event.parent_id && (event.parent_id !== event.event_id || checkParentID) ? ( diff --git a/src/app/note/components/metadata.tsx b/src/app/note/components/metadata.tsx index ed91df4c..e6120978 100644 --- a/src/app/note/components/metadata.tsx +++ b/src/app/note/components/metadata.tsx @@ -5,6 +5,7 @@ import { RelayContext } from "@shared/relayProvider"; import NoteZap from "@app/note/components/metadata/zap"; import PlusIcon from "@shared/icons/plus"; +import ZapIcon from "@shared/icons/zap"; import { Tooltip } from "@shared/tooltip"; import { READONLY_RELAYS } from "@stores/constants"; import { decode } from "light-bolt11-decoder"; @@ -66,10 +67,19 @@ export default function NoteMetadata({ }); return ( -
- - +
+
+ + + +
); } diff --git a/src/app/note/components/metadata/zap.tsx b/src/app/note/components/metadata/zap.tsx index 941a0f39..acd97b16 100644 --- a/src/app/note/components/metadata/zap.tsx +++ b/src/app/note/components/metadata/zap.tsx @@ -11,13 +11,8 @@ export default function NoteZap({ zaps }: { zaps: number }) { return ( ); diff --git a/src/app/note/components/quoteRepost.tsx b/src/app/note/components/quoteRepost.tsx index dfdf4401..1dbb9f20 100644 --- a/src/app/note/components/quoteRepost.tsx +++ b/src/app/note/components/quoteRepost.tsx @@ -12,9 +12,9 @@ export function NoteQuoteRepost({ event }: { event: any }) { href={`/app/note?id=${rootID}`} className="h-min w-full px-3 py-1.5" > -
-
-
+
+
+
diff --git a/src/app/note/components/rootNote.tsx b/src/app/note/components/rootNote.tsx index 36fe8dfa..255cdd25 100644 --- a/src/app/note/components/rootNote.tsx +++ b/src/app/note/components/rootNote.tsx @@ -75,7 +75,7 @@ export const RootNote = memo(function RootNote({
openNote(e)} onKeyDown={(e) => openNote(e)} - className="flex flex-col px-3" + className="flex flex-col px-5" > openNote(e)} onKeyDown={(e) => openNote(e)} - className="flex flex-col px-3" + className="flex flex-col px-5" > {data ? ( <> diff --git a/src/app/note/components/skeleton.tsx b/src/app/note/components/skeleton.tsx index 66056d3e..0835f29e 100644 --- a/src/app/note/components/skeleton.tsx +++ b/src/app/note/components/skeleton.tsx @@ -1,14 +1,14 @@ export function NoteSkeleton() { return (
-
-
+
+
-
+
diff --git a/src/app/note/components/user/default.tsx b/src/app/note/components/user/default.tsx index 8b9e857a..8cdf19ed 100644 --- a/src/app/note/components/user/default.tsx +++ b/src/app/note/components/user/default.tsx @@ -30,7 +30,7 @@ export function NoteDefaultUser({ />
-
+
{user?.nip05 || user?.name || shortenKey(pubkey)}
· diff --git a/src/app/note/components/user/repost.tsx b/src/app/note/components/user/repost.tsx index cda2237e..7de9bf60 100644 --- a/src/app/note/components/user/repost.tsx +++ b/src/app/note/components/user/repost.tsx @@ -30,13 +30,13 @@ export function NoteRepostUser({ />
-
+
{user?.nip05 || user?.name || shortenKey(pubkey)} - - {" "} - reposted -
+ + {" "} + reposted + · {dayjs().to(dayjs.unix(time), true)} diff --git a/src/app/space/components/following.tsx b/src/app/space/components/following.tsx new file mode 100644 index 00000000..838ad08c --- /dev/null +++ b/src/app/space/components/following.tsx @@ -0,0 +1,134 @@ +import { NoteBase } from "@app/note/components/base"; +import { NoteQuoteRepost } from "@app/note/components/quoteRepost"; +import { NoteSkeleton } from "@app/note/components/skeleton"; + +import { getNotes } from "@utils/storage"; + +import { useInfiniteQuery } from "@tanstack/react-query"; +import { useVirtualizer } from "@tanstack/react-virtual"; +import { useEffect, useRef } from "react"; + +const ITEM_PER_PAGE = 10; +const TIME = Math.floor(Date.now() / 1000); + +export function FollowingBlock() { + const { + status, + data, + fetchNextPage, + hasNextPage, + isFetching, + isFetchingNextPage, + }: any = useInfiniteQuery({ + queryKey: ["following"], + queryFn: async ({ pageParam = 0 }) => { + return await getNotes(TIME, ITEM_PER_PAGE, pageParam); + }, + getNextPageParam: (lastPage) => lastPage.nextCursor, + }); + + const allRows = data ? data.pages.flatMap((d: { data: any }) => d.data) : []; + const parentRef = useRef(); + + const rowVirtualizer = useVirtualizer({ + count: hasNextPage ? allRows.length + 1 : allRows.length, + getScrollElement: () => parentRef.current, + estimateSize: () => 400, + overscan: 2, + }); + + const itemsVirtualizer = rowVirtualizer.getVirtualItems(); + + useEffect(() => { + const [lastItem] = [...rowVirtualizer.getVirtualItems()].reverse(); + + if (!lastItem) { + return; + } + + if ( + lastItem.index >= allRows.length - 1 && + hasNextPage && + !isFetchingNextPage + ) { + fetchNextPage(); + } + }, [fetchNextPage, allRows.length, rowVirtualizer.getVirtualItems()]); + + return ( +
+
+

Following

+
+
+ {status === "loading" ? ( +
+
+ +
+
+ ) : ( +
+
+ {rowVirtualizer.getVirtualItems().map((virtualRow) => { + const note = allRows[virtualRow.index]; + if (note) { + if (note.kind === 1) { + return ( +
+ +
+ ); + } else { + return ( +
+ +
+ ); + } + } + })} +
+
+ )} +
+ {isFetching && !isFetchingNextPage && ( +
+
+ +
+
+ )} +
+
+
+ ); +} diff --git a/src/app/space/components/header.tsx b/src/app/space/components/header.tsx deleted file mode 100644 index fe69ee44..00000000 --- a/src/app/space/components/header.tsx +++ /dev/null @@ -1,58 +0,0 @@ -import { CreateViewModal } from "@app/space/components/views/createModal"; - -export function Header() { - return ( -
- -
- - - - - -
-
- -
-
- -
- -
- ); -} diff --git a/src/app/space/components/views/createModal.tsx b/src/app/space/components/views/createModal.tsx deleted file mode 100644 index 2b621d67..00000000 --- a/src/app/space/components/views/createModal.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import CancelIcon from "@icons/cancel"; -import PlusIcon from "@icons/plus"; - -import { Dialog, Transition } from "@headlessui/react"; -import { Fragment, useState } from "react"; - -export function CreateViewModal() { - const [isOpen, setIsOpen] = useState(false); - - const closeModal = () => { - setIsOpen(false); - }; - - const openModal = () => { - setIsOpen(true); - }; - - return ( - <> - - - - -
- -
- - -
-
-
- - Create a view - - -
- - View is specific feature help you pin who you want to see - in your feed. You can add maximum 5 people in a view. - -
-
-
- - -
-
-
- - ); -} diff --git a/src/app/space/pages/index.page.tsx b/src/app/space/pages/index.page.tsx index d9c4c95e..f42761b3 100644 --- a/src/app/space/pages/index.page.tsx +++ b/src/app/space/pages/index.page.tsx @@ -1,135 +1,22 @@ -import { NoteBase } from "@app/note/components/base"; -import { NoteQuoteRepost } from "@app/note/components/quoteRepost"; -import { NoteSkeleton } from "@app/note/components/skeleton"; -import { Header } from "@app/space/components/header"; - -import { getNotes } from "@utils/storage"; - -import { useInfiniteQuery } from "@tanstack/react-query"; -import { useVirtualizer } from "@tanstack/react-virtual"; -import { useEffect, useRef } from "react"; - -const ITEM_PER_PAGE = 10; -const TIME = Math.floor(Date.now() / 1000); +import { FollowingBlock } from "@app/space/components/following"; +import PlusIcon from "@shared/icons/plus"; export function Page() { - const { - status, - error, - data, - fetchNextPage, - hasNextPage, - isFetching, - isFetchingNextPage, - }: any = useInfiniteQuery({ - queryKey: ["following"], - queryFn: async ({ pageParam = 0 }) => { - return await getNotes(TIME, ITEM_PER_PAGE, pageParam); - }, - getNextPageParam: (lastPage) => lastPage.nextCursor, - }); - - const allRows = data ? data.pages.flatMap((d: { data: any }) => d.data) : []; - const parentRef = useRef(); - - const rowVirtualizer = useVirtualizer({ - count: hasNextPage ? allRows.length + 1 : allRows.length, - getScrollElement: () => parentRef.current, - estimateSize: () => 400, - overscan: 2, - }); - - const itemsVirtualizer = rowVirtualizer.getVirtualItems(); - - useEffect(() => { - const [lastItem] = [...rowVirtualizer.getVirtualItems()].reverse(); - - if (!lastItem) { - return; - } - - if ( - lastItem.index >= allRows.length - 1 && - hasNextPage && - !isFetchingNextPage - ) { - fetchNextPage(); - } - }, [fetchNextPage, allRows.length, rowVirtualizer.getVirtualItems()]); - return ( -
-
-
-

Following

-
-
- {status === "loading" ? ( -
-
- -
-
- ) : ( -
-
- {rowVirtualizer.getVirtualItems().map((virtualRow) => { - const note = allRows[virtualRow.index]; - if (note) { - if (note.kind === 1) { - return ( -
- -
- ); - } else { - return ( -
- -
- ); - } - } - })} -
-
- )} -
- {isFetching && !isFetchingNextPage && ( -
-
- -
-
- )} -
+
+ +
+
+
+
); }