feat: migrate frontend to new backend
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { RepostNote, TextNote, useArk } from "@lume/ark";
|
||||
import { ArrowRightCircleIcon, LoaderIcon, SearchIcon } from "@lume/icons";
|
||||
import { Event, Kind } from "@lume/types";
|
||||
import { EmptyFeed } from "@lume/ui";
|
||||
import { FETCH_LIMIT } from "@lume/utils";
|
||||
import { NDKEvent, NDKKind } from "@nostr-dev-kit/ndk";
|
||||
@@ -30,18 +31,7 @@ export function HomeRoute({ colKey }: { colKey: string }) {
|
||||
signal: AbortSignal;
|
||||
pageParam: number;
|
||||
}) => {
|
||||
if (!ark.account.contacts.length) return [];
|
||||
|
||||
const events = await ark.getInfiniteEvents({
|
||||
filter: {
|
||||
kinds: [NDKKind.Text, NDKKind.Repost],
|
||||
authors: ark.account.contacts,
|
||||
},
|
||||
limit: FETCH_LIMIT,
|
||||
pageParam,
|
||||
signal,
|
||||
});
|
||||
|
||||
const events = await ark.get_text_events(FETCH_LIMIT);
|
||||
return events;
|
||||
},
|
||||
getNextPageParam: (lastPage) => {
|
||||
@@ -54,11 +44,11 @@ export function HomeRoute({ colKey }: { colKey: string }) {
|
||||
refetchOnMount: false,
|
||||
});
|
||||
|
||||
const renderItem = (event: NDKEvent) => {
|
||||
const renderItem = (event: Event) => {
|
||||
switch (event.kind) {
|
||||
case NDKKind.Text:
|
||||
case Kind.Text:
|
||||
return <TextNote key={event.id} event={event} className="mt-3" />;
|
||||
case NDKKind.Repost:
|
||||
case Kind.Repost:
|
||||
return <RepostNote key={event.id} event={event} className="mt-3" />;
|
||||
default:
|
||||
return <TextNote key={event.id} event={event} className="mt-3" />;
|
||||
@@ -81,6 +71,7 @@ export function HomeRoute({ colKey }: { colKey: string }) {
|
||||
};
|
||||
}, []);
|
||||
|
||||
/*
|
||||
if (!ark.account.contacts.length) {
|
||||
return (
|
||||
<div className="px-3 mt-3">
|
||||
@@ -95,6 +86,7 @@ export function HomeRoute({ colKey }: { colKey: string }) {
|
||||
</div>
|
||||
);
|
||||
}
|
||||
*/
|
||||
|
||||
return (
|
||||
<div className="w-full h-full">
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
import { Column, useArk } from "@lume/ark";
|
||||
import { Column } from "@lume/ark";
|
||||
import { IColumn } from "@lume/types";
|
||||
import { EventRoute, SuggestRoute, UserRoute } from "@lume/ui";
|
||||
import { NDKEvent, NDKKind } from "@nostr-dev-kit/ndk";
|
||||
import { useQueryClient } from "@tanstack/react-query";
|
||||
import { useRef } from "react";
|
||||
import { HomeRoute } from "./home";
|
||||
|
||||
export function Timeline({ column }: { column: IColumn }) {
|
||||
const colKey = `timeline-${column.id}`;
|
||||
const ark = useArk();
|
||||
const queryClient = useQueryClient();
|
||||
const since = useRef(Math.floor(Date.now() / 1000));
|
||||
// const ark = useArk();
|
||||
// const queryClient = useQueryClient();
|
||||
// const since = useRef(Math.floor(Date.now() / 1000));
|
||||
|
||||
/*
|
||||
const refresh = async (events: NDKEvent[]) => {
|
||||
const uniqEvents = new Set(events);
|
||||
await queryClient.setQueryData(
|
||||
@@ -22,11 +20,12 @@ export function Timeline({ column }: { column: IColumn }) {
|
||||
}),
|
||||
);
|
||||
};
|
||||
*/
|
||||
|
||||
return (
|
||||
<Column.Root>
|
||||
<Column.Header id={column.id} queryKey={[colKey]} title="Timeline" />
|
||||
{ark.account.contacts.length ? (
|
||||
{/*<Column.Header id={column.id} queryKey={[colKey]} title="Timeline" />*/}
|
||||
{/*ark.account.contacts.length ? (
|
||||
<Column.Live
|
||||
filter={{
|
||||
kinds: [NDKKind.Text, NDKKind.Repost],
|
||||
@@ -35,15 +34,17 @@ export function Timeline({ column }: { column: IColumn }) {
|
||||
}}
|
||||
onClick={refresh}
|
||||
/>
|
||||
) : null}
|
||||
) : null*/}
|
||||
<Column.Content>
|
||||
<Column.Route path="/" element={<HomeRoute colKey={colKey} />} />
|
||||
<Column.Route path="/events/:id" element={<EventRoute />} />
|
||||
<Column.Route path="/users/:id" element={<UserRoute />} />
|
||||
<Column.Route
|
||||
path="/suggest"
|
||||
element={<SuggestRoute queryKey={[colKey]} />}
|
||||
/>
|
||||
{/*
|
||||
<Column.Route path="/events/:id" element={<EventRoute />} />
|
||||
<Column.Route path="/users/:id" element={<UserRoute />} />
|
||||
<Column.Route
|
||||
path="/suggest"
|
||||
element={<SuggestRoute queryKey={[colKey]} />}
|
||||
/>
|
||||
*/}
|
||||
</Column.Content>
|
||||
</Column.Root>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user