Skip to content

Commit

Permalink
add follow buttons in people search results
Browse files Browse the repository at this point in the history
  • Loading branch information
w3irdrobot committed Dec 1, 2023
1 parent 601ecaa commit a57a53c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/app/src/Element/Feed/UsersFeed.tsx
Original file line number Diff line number Diff line change
@@ -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 <PageSpinner />;

return <FollowListBase pubkeys={usersFeed} showAbout={true} />;
}
6 changes: 6 additions & 0 deletions packages/app/src/Pages/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -49,6 +50,11 @@ const SearchPage = () => {
return null;
}

if (tab.value == PROFILES ) {
// render UsersFeed
return <UsersFeed keyword={keyword} />;
}

const pf = tab.value == PROFILES;
return (
<>
Expand Down

0 comments on commit a57a53c

Please sign in to comment.