followed-by-friends feed
This commit is contained in:
parent
1b70815109
commit
85846422dd
@ -10,6 +10,7 @@ import { Newest } from "@/Login";
|
||||
|
||||
export type RootTab =
|
||||
| "following"
|
||||
| "followed-by-friends"
|
||||
| "conversations"
|
||||
| "trending-notes"
|
||||
| "trending-people"
|
||||
@ -53,13 +54,13 @@ export function rootTabItems(base: string, pubKey: string | undefined, tags: New
|
||||
),
|
||||
},
|
||||
{
|
||||
tab: "trending-people",
|
||||
path: `${base}/trending/people`,
|
||||
show: true,
|
||||
tab: "followed-by-friends",
|
||||
path: `${base}/followed-by-friends`,
|
||||
show: Boolean(pubKey),
|
||||
element: (
|
||||
<>
|
||||
<Icon name="user-up" />
|
||||
<FormattedMessage defaultMessage="Trending People" id="CVWeJ6" />
|
||||
<Icon name="user-v2" />
|
||||
<FormattedMessage defaultMessage="Followed by friends" id="voxBKC" />
|
||||
</>
|
||||
),
|
||||
},
|
||||
|
@ -1,7 +1,7 @@
|
||||
import "./Timeline.css";
|
||||
import { FormattedMessage } from "react-intl";
|
||||
import { useCallback, useMemo, useState } from "react";
|
||||
import { TaggedNostrEvent, EventKind } from "@snort/system";
|
||||
import { TaggedNostrEvent, EventKind, socialGraphInstance } from "@snort/system";
|
||||
|
||||
import { dedupeByPubkey, findTag } from "@/SnortUtils";
|
||||
import useTimelineFeed, { TimelineFeed, TimelineSubject } from "@/Feed/TimelineFeed";
|
||||
@ -16,6 +16,7 @@ export interface TimelineProps {
|
||||
postsOnly: boolean;
|
||||
subject: TimelineSubject;
|
||||
method: "TIME_RANGE" | "LIMIT_UNTIL";
|
||||
followDistance?: number;
|
||||
ignoreModeration?: boolean;
|
||||
window?: number;
|
||||
now?: number;
|
||||
@ -44,13 +45,20 @@ const Timeline = (props: TimelineProps) => {
|
||||
const { muted, isEventMuted } = useModeration();
|
||||
const filterPosts = useCallback(
|
||||
(nts: readonly TaggedNostrEvent[]) => {
|
||||
const checkFollowDistance = (a: TaggedNostrEvent) => {
|
||||
if (props.followDistance === undefined) {
|
||||
return true;
|
||||
}
|
||||
const followDistance = socialGraphInstance.getFollowDistance(a.pubkey);
|
||||
return followDistance === props.followDistance;
|
||||
};
|
||||
const a = [...nts.filter(a => a.kind !== EventKind.LiveEvent)];
|
||||
props.noSort || a.sort((a, b) => b.created_at - a.created_at);
|
||||
return a
|
||||
?.filter(a => (props.postsOnly ? !a.tags.some(b => b[0] === "e") : true))
|
||||
.filter(a => props.ignoreModeration || !isEventMuted(a));
|
||||
.filter(a => (props.ignoreModeration || !isEventMuted(a)) && checkFollowDistance(a));
|
||||
},
|
||||
[props.postsOnly, muted, props.ignoreModeration],
|
||||
[props.postsOnly, muted, props.ignoreModeration, props.followDistance],
|
||||
);
|
||||
|
||||
const mainFeed = useMemo(() => {
|
||||
|
@ -10,7 +10,6 @@ import { TimelineSubject } from "@/Feed/TimelineFeed";
|
||||
import { debounce, getCurrentRefCode, getRelayName, sha256 } from "@/SnortUtils";
|
||||
import useLogin from "@/Hooks/useLogin";
|
||||
import Discover from "@/Pages/Discover";
|
||||
import TrendingUsers from "@/Element/Trending/TrendingUsers";
|
||||
import TrendingNotes from "@/Element/Trending/TrendingPosts";
|
||||
import HashTagsPage from "@/Pages/HashTagsPage";
|
||||
import SuggestedProfiles from "@/Element/SuggestedProfiles";
|
||||
@ -147,6 +146,18 @@ export const GlobalTab = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export const FollowedByFriendsTab = () => {
|
||||
const { publicKey } = useLogin();
|
||||
const subject: TimelineSubject = {
|
||||
type: "global",
|
||||
items: [],
|
||||
discriminator: `followed-by-friends-${publicKey}`,
|
||||
streams: true,
|
||||
};
|
||||
|
||||
return <Timeline followDistance={2} subject={subject} postsOnly={false} method={"TIME_RANGE"} />;
|
||||
};
|
||||
|
||||
export const NotesTab = () => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
const deckContext = useContext(DeckContext);
|
||||
@ -209,6 +220,10 @@ export const RootTabRoutes = [
|
||||
path: "notes",
|
||||
element: <NotesTab />,
|
||||
},
|
||||
{
|
||||
path: "followed-by-friends",
|
||||
element: <FollowedByFriendsTab />,
|
||||
},
|
||||
{
|
||||
path: "conversations",
|
||||
element: <ConversationsTab />,
|
||||
@ -225,14 +240,6 @@ export const RootTabRoutes = [
|
||||
path: "trending/notes",
|
||||
element: <TrendingNotes />,
|
||||
},
|
||||
{
|
||||
path: "trending/people",
|
||||
element: (
|
||||
<div className="p">
|
||||
<TrendingUsers />
|
||||
</div>
|
||||
),
|
||||
},
|
||||
{
|
||||
path: "trending/hashtags",
|
||||
element: <TrendingHashtags />,
|
||||
|
@ -1489,6 +1489,9 @@
|
||||
"vlbWtt": {
|
||||
"defaultMessage": "Get a free one"
|
||||
},
|
||||
"voxBKC": {
|
||||
"defaultMessage": "Followed by friends"
|
||||
},
|
||||
"vrTOHJ": {
|
||||
"defaultMessage": "{amount} sats"
|
||||
},
|
||||
|
@ -491,6 +491,7 @@
|
||||
"vZ4quW": "NIP-05 is a DNS based verification spec which helps to validate you as a real user.",
|
||||
"vhlWFg": "Poll Options",
|
||||
"vlbWtt": "Get a free one",
|
||||
"voxBKC": "Followed by friends",
|
||||
"vrTOHJ": "{amount} sats",
|
||||
"vxwnbh": "Amount of work to apply to all published events",
|
||||
"w1Fanr": "Business",
|
||||
|
Loading…
x
Reference in New Issue
Block a user