feat: add suggest screen

This commit is contained in:
2024-01-20 14:51:13 +07:00
parent b726ae3c7c
commit 9fcdac4edb
14 changed files with 447 additions and 39 deletions

View File

@@ -1,6 +1,8 @@
import { TextNote, useArk } from "@lume/ark";
import { ArrowRightCircleIcon, LoaderIcon } from "@lume/icons";
import { InterestModal } from "@lume/ark/src/components/column/interestModal";
import { ArrowRightCircleIcon, ForyouIcon, LoaderIcon } from "@lume/icons";
import { useStorage } from "@lume/storage";
import { EmptyFeed } from "@lume/ui";
import { FETCH_LIMIT } from "@lume/utils";
import { NDKEvent, NDKKind } from "@nostr-dev-kit/ndk";
import { useInfiniteQuery, useQueryClient } from "@tanstack/react-query";
@@ -31,10 +33,14 @@ export function HomeRoute({ colKey }: { colKey: string }) {
signal: AbortSignal;
pageParam: number;
}) => {
if (!storage.interests?.hashtags) return [];
const events = await ark.getInfiniteEvents({
filter: {
kinds: [NDKKind.Text],
"#t": storage.interests.hashtags,
"#t": storage.interests.hashtags.map((item: string) =>
item.replace("#", "").toLowerCase(),
),
},
limit: FETCH_LIMIT,
pageParam,
@@ -81,6 +87,21 @@ export function HomeRoute({ colKey }: { colKey: string }) {
};
}, []);
if (!storage.interests?.hashtags?.length) {
return (
<div className="px-3 mt-3">
<EmptyFeed subtext="You can more interests to build up your timeline" />
<InterestModal
queryKey={[colKey]}
className="mt-3 w-full inline-flex items-center justify-center rounded-lg h-9 bg-blue-500 hover:bg-blue-600 text-white"
>
<ForyouIcon className="size-5" />
Add interest
</InterestModal>
</div>
);
}
return (
<div className="w-full h-full">
<VList ref={ref} cache={cache} overscan={2} className="flex-1 px-3">

View File

@@ -33,14 +33,18 @@ export function ForYou({ column }: { column: IColumn }) {
title="For You"
icon={<ForyouIcon className="size-4" />}
/>
<Column.Live
filter={{
kinds: [NDKKind.Text],
"#t": storage.interests.hashtags,
since: since.current,
}}
onClick={refresh}
/>
{storage.interests?.hashtags ? (
<Column.Live
filter={{
kinds: [NDKKind.Text],
"#t": storage.interests.hashtags.map((item: string) =>
item.replace("#", "").toLowerCase(),
),
since: since.current,
}}
onClick={refresh}
/>
) : null}
<Column.Content>
<Column.Route path="/" element={<HomeRoute colKey={colKey} />} />
<Column.Route path="/events/:id" element={<EventRoute />} />