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