refactor: move new users page to task

This commit is contained in:
2024-09-12 14:00:00 +01:00
parent b238da4024
commit 7b6a813c8a
7 changed files with 52 additions and 41 deletions

View File

@ -0,0 +1,33 @@
import { CachedMetadata } from "@snort/system";
import { FormattedMessage } from "react-intl";
import { Link } from "react-router-dom";
import { BaseUITask } from "@/Components/Tasks/index";
import { LoginSession } from "@/Utils/Login";
export class FollowMorePeopleTask extends BaseUITask {
id = "follow-more-people";
check(_meta: CachedMetadata, session: LoginSession): boolean {
return !this.state.muted && (session.state.follows?.length ?? 0) < 10;
}
render() {
return (
<>
<p>
<FormattedMessage
defaultMessage="It looks like you dont follow enough people, take a look at {newUsersPage} to discover people to follow!"
values={{
newUsersPage: (
<Link to={"/discover"}>
<FormattedMessage defaultMessage="new users page" />
</Link>
),
}}
/>
</p>
</>
);
}
}

View File

@ -11,6 +11,7 @@ import useLogin from "@/Hooks/useLogin";
import { BackupKeyTask } from "./BackupKey"; import { BackupKeyTask } from "./BackupKey";
import { DonateTask } from "./DonateTask"; import { DonateTask } from "./DonateTask";
import { FollowMorePeopleTask } from "./FollowMorePeople";
import { Nip5Task } from "./Nip5Task"; import { Nip5Task } from "./Nip5Task";
import { NoticeZapPoolDefault } from "./NoticeZapPool"; import { NoticeZapPoolDefault } from "./NoticeZapPool";
import { RenewSubTask } from "./RenewSubscription"; import { RenewSubTask } from "./RenewSubscription";
@ -20,7 +21,7 @@ class TaskStore extends ExternalStore<Array<UITask>> {
constructor() { constructor() {
super(); super();
const AllTasks: Array<UITask> = [new BackupKeyTask(), new Nip5Task()]; const AllTasks: Array<UITask> = [new BackupKeyTask(), new FollowMorePeopleTask(), new Nip5Task()];
if (CONFIG.features.zapPool) { if (CONFIG.features.zapPool) {
AllTasks.push(new NoticeZapPoolDefault()); AllTasks.push(new NoticeZapPoolDefault());
} }

View File

@ -1,7 +1,6 @@
import { useState } from "react"; import { useState } from "react";
import { useIntl } from "react-intl"; import { useIntl } from "react-intl";
import SuggestedProfiles from "@/Components/SuggestedProfiles";
import { Tab, TabSelector } from "@/Components/TabSelectors/TabSelectors"; import { Tab, TabSelector } from "@/Components/TabSelectors/TabSelectors";
import TrendingNotes from "@/Components/Trending/TrendingPosts"; import TrendingNotes from "@/Components/Trending/TrendingPosts";
import TrendingUsers from "@/Components/Trending/TrendingUsers"; import TrendingUsers from "@/Components/Trending/TrendingUsers";
@ -10,20 +9,21 @@ export default function Discover() {
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
// tabs // tabs
const Tabs = { const Tabs = {
Follows: { text: formatMessage({ defaultMessage: "Suggested Follows", id: "C8HhVE" }), value: 0 },
Posts: { text: formatMessage({ defaultMessage: "Trending Notes", id: "Ix8l+B" }), value: 1 }, Posts: { text: formatMessage({ defaultMessage: "Trending Notes", id: "Ix8l+B" }), value: 1 },
Profiles: { text: formatMessage({ defaultMessage: "Trending People", id: "CVWeJ6" }), value: 2 }, Profiles: { text: formatMessage({ defaultMessage: "Trending People", id: "CVWeJ6" }), value: 0 },
}; };
const [tab, setTab] = useState<Tab>(Tabs.Follows); const [tab, setTab] = useState<Tab>(Tabs.Profiles);
function renderTab() { function renderTab() {
switch (tab.value) { switch (tab.value) {
case 0:
return <SuggestedProfiles />;
case 1: case 1:
return <TrendingNotes />; return <TrendingNotes />;
case 2: case 0:
return <TrendingUsers />; return (
<div className="p">
<TrendingUsers />
</div>
);
} }
return null; return null;
} }
@ -31,7 +31,7 @@ export default function Discover() {
return ( return (
<> <>
<div className="tabs p"> <div className="tabs p">
{[Tabs.Follows, Tabs.Posts, Tabs.Profiles].map(a => ( {[Tabs.Profiles, Tabs.Posts].map(a => (
<TabSelector key={a.value} tab={tab} setTab={setTab} t={a} /> <TabSelector key={a.value} tab={tab} setTab={setTab} t={a} />
))} ))}
</div> </div>

View File

@ -1,31 +1,9 @@
import { NostrEvent, NostrLink } from "@snort/system"; import { NostrEvent, NostrLink } from "@snort/system";
import { useContext, useMemo } from "react"; import { useContext, useMemo } from "react";
import { FormattedMessage } from "react-intl";
import { Link } from "react-router-dom";
import TimelineFollows from "@/Components/Feed/TimelineFollows"; import TimelineFollows from "@/Components/Feed/TimelineFollows";
import { TaskList } from "@/Components/Tasks/TaskList"; import { TaskList } from "@/Components/Tasks/TaskList";
import useFollowsControls from "@/Hooks/useFollowControls";
import { DeckContext } from "@/Pages/Deck/DeckLayout"; import { DeckContext } from "@/Pages/Deck/DeckLayout";
import messages from "@/Pages/messages";
const FollowsHint = () => {
const { followList } = useFollowsControls();
if (followList.length === 0) {
return (
<FormattedMessage
{...messages.NoFollows}
values={{
newUsersPage: (
<Link to={"/discover"}>
<FormattedMessage {...messages.NewUsers} />
</Link>
),
}}
/>
);
}
};
export const NotesTab = () => { export const NotesTab = () => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars // eslint-disable-next-line @typescript-eslint/no-unused-vars
@ -42,7 +20,6 @@ export const NotesTab = () => {
return ( return (
<> <>
<FollowsHint />
<TaskList /> <TaskList />
<TimelineFollows postsOnly={true} noteOnClick={noteOnClick} /> <TimelineFollows postsOnly={true} noteOnClick={noteOnClick} />
</> </>

View File

@ -4,10 +4,6 @@ export default defineMessages({
Login: { defaultMessage: "Login", id: "AyGauy" }, Login: { defaultMessage: "Login", id: "AyGauy" },
Global: { defaultMessage: "Global", id: "EWyQH5" }, Global: { defaultMessage: "Global", id: "EWyQH5" },
NewUsers: { defaultMessage: "New users page", id: "NndBJE" }, NewUsers: { defaultMessage: "New users page", id: "NndBJE" },
NoFollows: {
defaultMessage: "Hmm nothing here.. Checkout {newUsersPage} to follow some recommended nostrich's!",
id: "NdOYJJ",
},
Reactions: { defaultMessage: "Reactions", id: "XgWvGA" }, Reactions: { defaultMessage: "Reactions", id: "XgWvGA" },
Followers: { defaultMessage: "Followers", id: "pzTOmv" }, Followers: { defaultMessage: "Followers", id: "pzTOmv" },
FollowersCount: { defaultMessage: "{n} Followers", id: "3tVy+Z" }, FollowersCount: { defaultMessage: "{n} Followers", id: "3tVy+Z" },

View File

@ -898,9 +898,6 @@
"NAuFNH": { "NAuFNH": {
"defaultMessage": "You already have a subscription of this type, please renew or pay" "defaultMessage": "You already have a subscription of this type, please renew or pay"
}, },
"NdOYJJ": {
"defaultMessage": "Hmm nothing here.. Checkout {newUsersPage} to follow some recommended nostrich's!"
},
"NepkXH": { "NepkXH": {
"defaultMessage": "Can't vote with {amount} sats, please set a different default zap amount" "defaultMessage": "Can't vote with {amount} sats, please set a different default zap amount"
}, },
@ -1217,6 +1214,9 @@
"YDURw6": { "YDURw6": {
"defaultMessage": "Service URL" "defaultMessage": "Service URL"
}, },
"YQZY/S": {
"defaultMessage": "It looks like you dont follow enough people, take a look at {newUsersPage} to discover people to follow!"
},
"YR2I9M": { "YR2I9M": {
"defaultMessage": "No keys, no {app}, There is no way to reset it if you don't back up. It only takes a minute." "defaultMessage": "No keys, no {app}, There is no way to reset it if you don't back up. It only takes a minute."
}, },
@ -1578,6 +1578,9 @@
"iYc3Ld": { "iYc3Ld": {
"defaultMessage": "Payments" "defaultMessage": "Payments"
}, },
"icCxlA": {
"defaultMessage": "new users page"
},
"ieGrWo": { "ieGrWo": {
"defaultMessage": "Follow" "defaultMessage": "Follow"
}, },

View File

@ -297,7 +297,6 @@
"N2IrpM": "Confirm", "N2IrpM": "Confirm",
"NAidKb": "Notifications", "NAidKb": "Notifications",
"NAuFNH": "You already have a subscription of this type, please renew or pay", "NAuFNH": "You already have a subscription of this type, please renew or pay",
"NdOYJJ": "Hmm nothing here.. Checkout {newUsersPage} to follow some recommended nostrich's!",
"NepkXH": "Can't vote with {amount} sats, please set a different default zap amount", "NepkXH": "Can't vote with {amount} sats, please set a different default zap amount",
"NndBJE": "New users page", "NndBJE": "New users page",
"Nr9Yyx": "Reposts", "Nr9Yyx": "Reposts",
@ -403,6 +402,7 @@
"Xopqkl": "Your default zap amount is {number} sats, example values are calculated from this.", "Xopqkl": "Your default zap amount is {number} sats, example values are calculated from this.",
"YDMrKK": "Users", "YDMrKK": "Users",
"YDURw6": "Service URL", "YDURw6": "Service URL",
"YQZY/S": "It looks like you dont follow enough people, take a look at {newUsersPage} to discover people to follow!",
"YR2I9M": "No keys, no {app}, There is no way to reset it if you don't back up. It only takes a minute.", "YR2I9M": "No keys, no {app}, There is no way to reset it if you don't back up. It only takes a minute.",
"YU7ZYp": "Public Chat", "YU7ZYp": "Public Chat",
"YXA3AH": "Enable reactions", "YXA3AH": "Enable reactions",
@ -523,6 +523,7 @@
"iNWbVV": "Handle", "iNWbVV": "Handle",
"iXPL0Z": "Can't login with private key on an insecure connection, please use a Nostr key manager extension instead", "iXPL0Z": "Can't login with private key on an insecure connection, please use a Nostr key manager extension instead",
"iYc3Ld": "Payments", "iYc3Ld": "Payments",
"icCxlA": "new users page",
"ieGrWo": "Follow", "ieGrWo": "Follow",
"ipHVx5": "Generate Invoice", "ipHVx5": "Generate Invoice",
"itPgxd": "Profile", "itPgxd": "Profile",