feat: add for you column

This commit is contained in:
2024-01-20 09:06:00 +07:00
parent a3460418f6
commit b726ae3c7c
25 changed files with 511 additions and 91 deletions

View File

@@ -57,16 +57,12 @@ export function HomeRoute({ colKey }: { colKey: string }) {
};
}
},
select: (data) => data?.pages.flatMap((page) => page),
staleTime: 120 * 1000,
refetchOnWindowFocus: false,
refetchOnMount: false,
});
const allEvents = useMemo(
() => (data ? data.pages.flatMap((page) => page) : []),
[data],
);
const renderItem = (event: NDKEvent) => {
switch (event.kind) {
case NDKKind.Text:
@@ -110,7 +106,7 @@ export function HomeRoute({ colKey }: { colKey: string }) {
<LoaderIcon className="size-5 animate-spin" />
</div>
) : (
allEvents.map((item) => renderItem(item))
data.map((item) => renderItem(item))
)}
<div className="flex items-center justify-center h-16">
{hasNextPage ? (

View File

@@ -13,7 +13,7 @@ export function Timeline({ column }: { column: IColumn }) {
const queryClient = useQueryClient();
const since = useRef(Math.floor(Date.now() / 1000));
const refreshTimeline = async (events: NDKEvent[]) => {
const refresh = async (events: NDKEvent[]) => {
const uniqEvents = new Set(events);
await queryClient.setQueryData(
[colKey],
@@ -40,7 +40,7 @@ export function Timeline({ column }: { column: IColumn }) {
: ark.account.contacts,
since: since.current,
}}
onClick={refreshTimeline}
onClick={refresh}
/>
<Column.Content>
<Column.Route path="/" element={<HomeRoute colKey={colKey} />} />