feat: posts only feed
This commit is contained in:
@ -7,17 +7,18 @@ import NoteReaction from "./NoteReaction";
|
|||||||
|
|
||||||
export interface TimelineProps {
|
export interface TimelineProps {
|
||||||
global: boolean,
|
global: boolean,
|
||||||
|
postsOnly: boolean,
|
||||||
pubkeys: HexKey[]
|
pubkeys: HexKey[]
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of notes by pubkeys
|
* A list of notes by pubkeys
|
||||||
*/
|
*/
|
||||||
export default function Timeline({ global, pubkeys }: TimelineProps) {
|
export default function Timeline({ global, pubkeys, postsOnly = false }: TimelineProps) {
|
||||||
const { main, others } = useTimelineFeed(pubkeys, global);
|
const { main, others } = useTimelineFeed(pubkeys, global);
|
||||||
|
|
||||||
const mainFeed = useMemo(() => {
|
const mainFeed = useMemo(() => {
|
||||||
return main?.sort((a, b) => b.created_at - a.created_at);
|
return main?.sort((a, b) => b.created_at - a.created_at)?.filter(a => postsOnly ? !a.tags.some(b => b[0] === "e") : true);
|
||||||
}, [main]);
|
}, [main]);
|
||||||
|
|
||||||
function eventElement(e: TaggedRawEvent) {
|
function eventElement(e: TaggedRawEvent) {
|
||||||
|
@ -84,7 +84,7 @@ export default function ProfilePage() {
|
|||||||
function tabContent() {
|
function tabContent() {
|
||||||
switch (tab) {
|
switch (tab) {
|
||||||
case ProfileTab.Notes:
|
case ProfileTab.Notes:
|
||||||
return <Timeline key={id} pubkeys={[id]} global={false} />;
|
return <Timeline key={id} pubkeys={[id]} global={false} postsOnly={false} />;
|
||||||
case ProfileTab.Follows: {
|
case ProfileTab.Follows: {
|
||||||
if (isMe) {
|
if (isMe) {
|
||||||
return (
|
return (
|
||||||
|
@ -8,13 +8,14 @@ import { RootState } from "../state/Store";
|
|||||||
import { HexKey } from "../nostr";
|
import { HexKey } from "../nostr";
|
||||||
|
|
||||||
const RootTab = {
|
const RootTab = {
|
||||||
Follows: 0,
|
Posts: 0,
|
||||||
Global: 1
|
PostsAndReplies: 1,
|
||||||
|
Global: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function RootPage() {
|
export default function RootPage() {
|
||||||
const [loggedOut, pubKey, follows] = useSelector<RootState, [boolean | undefined, HexKey | undefined, HexKey[]]>(s => [s.login.loggedOut, s.login.publicKey, s.login.follows]);
|
const [loggedOut, pubKey, follows] = useSelector<RootState, [boolean | undefined, HexKey | undefined, HexKey[]]>(s => [s.login.loggedOut, s.login.publicKey, s.login.follows]);
|
||||||
const [tab, setTab] = useState(RootTab.Follows);
|
const [tab, setTab] = useState(RootTab.Posts);
|
||||||
|
|
||||||
function followHints() {
|
function followHints() {
|
||||||
if (follows?.length === 0 && pubKey && tab !== RootTab.Global) {
|
if (follows?.length === 0 && pubKey && tab !== RootTab.Global) {
|
||||||
@ -29,15 +30,18 @@ export default function RootPage() {
|
|||||||
{pubKey ? <>
|
{pubKey ? <>
|
||||||
<NoteCreator show={true} autoFocus={false} />
|
<NoteCreator show={true} autoFocus={false} />
|
||||||
<div className="tabs root-tabs">
|
<div className="tabs root-tabs">
|
||||||
<div className={`root-tab f-1 ${tab === RootTab.Follows ? "active" : ""}`} onClick={() => setTab(RootTab.Follows)}>
|
<div className={`root-tab f-1 ${tab === RootTab.Posts ? "active" : ""}`} onClick={() => setTab(RootTab.Posts)}>
|
||||||
Follows
|
Posts
|
||||||
|
</div>
|
||||||
|
<div className={`root-tab f-1 ${tab === RootTab.PostsAndReplies ? "active" : ""}`} onClick={() => setTab(RootTab.PostsAndReplies)}>
|
||||||
|
Posts & Replies
|
||||||
</div>
|
</div>
|
||||||
<div className={`root-tab f-1 ${tab === RootTab.Global ? "active" : ""}`} onClick={() => setTab(RootTab.Global)}>
|
<div className={`root-tab f-1 ${tab === RootTab.Global ? "active" : ""}`} onClick={() => setTab(RootTab.Global)}>
|
||||||
Global
|
Global
|
||||||
</div>
|
</div>
|
||||||
</div></> : null}
|
</div></> : null}
|
||||||
{followHints()}
|
{followHints()}
|
||||||
<Timeline key={tab} pubkeys={follows} global={loggedOut || tab === RootTab.Global} />
|
<Timeline key={tab} pubkeys={follows} global={loggedOut || tab === RootTab.Global} postsOnly={tab === RootTab.Posts} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
Reference in New Issue
Block a user