From a57a53ca76a9090b2c7b6a3cb80ff1f2efa2a750 Mon Sep 17 00:00:00 2001 From: w3irdrobot Date: Fri, 1 Dec 2023 17:27:26 -0500 Subject: [PATCH] add follow buttons in people search results --- packages/app/src/Element/Feed/UsersFeed.tsx | 31 +++++++++++++++++++++ packages/app/src/Pages/SearchPage.tsx | 6 ++++ 2 files changed, 37 insertions(+) create mode 100644 packages/app/src/Element/Feed/UsersFeed.tsx diff --git a/packages/app/src/Element/Feed/UsersFeed.tsx b/packages/app/src/Element/Feed/UsersFeed.tsx new file mode 100644 index 000000000..03d42de59 --- /dev/null +++ b/packages/app/src/Element/Feed/UsersFeed.tsx @@ -0,0 +1,31 @@ +import { useCallback, useMemo } from "react"; +import { TaggedNostrEvent } from "@snort/system"; + +import useTimelineFeed, { TimelineFeed } from "@/Feed/TimelineFeed"; +import FollowListBase from "@/Element/User/FollowListBase"; +import PageSpinner from "@/Element/PageSpinner"; +import useModeration from "@/Hooks/useModeration"; + +export default function UsersFeed({ keyword, sortPopular = true }: { keyword: string; sortPopular?: boolean }) { + const feed: TimelineFeed = useTimelineFeed( + { + type: "profile_keyword", + items: [keyword + (sortPopular ? " sort:popular" : "")], + discriminator: keyword, + }, + { method: "LIMIT_UNTIL" }, + ); + + const { muted, isEventMuted } = useModeration(); + const filterPosts = useCallback( + (nts: readonly TaggedNostrEvent[]) => { + return nts.filter(a => !isEventMuted(a)); + }, + [muted], + ); + const usersFeed = useMemo(() => filterPosts(feed.main ?? []).map(p => p.pubkey), [feed, filterPosts]); + + if (!usersFeed) return ; + + return ; +} diff --git a/packages/app/src/Pages/SearchPage.tsx b/packages/app/src/Pages/SearchPage.tsx index a7a16bfb6..f48f6fe69 100644 --- a/packages/app/src/Pages/SearchPage.tsx +++ b/packages/app/src/Pages/SearchPage.tsx @@ -8,6 +8,7 @@ import { router } from "@/index"; import TrendingUsers from "@/Element/Trending/TrendingUsers"; import TrendingNotes from "@/Element/Trending/TrendingPosts"; +import UsersFeed from "@/Element/Feed/UsersFeed"; const NOTES = 0; const PROFILES = 1; @@ -49,6 +50,11 @@ const SearchPage = () => { return null; } + if (tab.value == PROFILES ) { + // render UsersFeed + return ; + } + const pf = tab.value == PROFILES; return ( <>