From 01c15c30a47c1982e6bc22a64b3be3a0f4958ab6 Mon Sep 17 00:00:00 2001 From: Alejandro Gomez Date: Sat, 28 Jan 2023 19:30:39 +0100 Subject: [PATCH] separate mute and blocked tabs --- src/Element/BlockList.tsx | 30 +++++++++++++++++++++--------- src/Pages/ProfilePage.tsx | 17 ++++++++++++----- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/Element/BlockList.tsx b/src/Element/BlockList.tsx index 7125f0f..bcf91d5 100644 --- a/src/Element/BlockList.tsx +++ b/src/Element/BlockList.tsx @@ -8,20 +8,32 @@ import ProfilePreview from "Element/ProfilePreview"; import useMutedFeed, { getMuted } from "Feed/MuteList"; import useModeration from "Hooks/useModeration"; -export default function BlockList() { +interface BlockListProps { + variant: "muted" | "blocked" +} + +export default function BlockList({ variant }: BlockListProps) { const { publicKey } = useSelector((s: RootState) => s.login) const { blocked, muted } = useModeration(); return (
-

Muted ({muted.length})

- {muted.map(a => { - return } pubkey={a} options={{ about: false }} key={a} /> - })} -

Blocked ({blocked.length})

- {blocked.map(a => { - return } pubkey={a} options={{ about: false }} key={a} /> - })} + {variant === "muted" && ( + <> +

{muted.length} muted

+ {muted.map(a => { + return } pubkey={a} options={{ about: false }} key={a} /> + })} + + )} + {variant === "blocked" && ( + <> +

{blocked.length} blocked

+ {blocked.map(a => { + return } pubkey={a} options={{ about: false }} key={a} /> + })} + + )}
) } diff --git a/src/Pages/ProfilePage.tsx b/src/Pages/ProfilePage.tsx index adddf75..3724f55 100644 --- a/src/Pages/ProfilePage.tsx +++ b/src/Pages/ProfilePage.tsx @@ -30,7 +30,8 @@ enum ProfileTab { Reactions = "Reactions", Followers = "Followers", Follows = "Follows", - Muted = "Muted" + Muted = "Muted", + Blocked = "Blocked" }; export default function ProfilePage() { @@ -124,7 +125,10 @@ export default function ProfilePage() { return } case ProfileTab.Muted: { - return isMe ? : + return isMe ? : + } + case ProfileTab.Blocked: { + return isMe ? : null } } } @@ -165,6 +169,10 @@ export default function ProfilePage() { ) } + function renderTab(v: ProfileTab) { + return
setTab(v)}>{v}
+ } + return ( <>
@@ -175,9 +183,8 @@ export default function ProfilePage() {
- {[ProfileTab.Notes, ProfileTab.Followers, ProfileTab.Follows, ProfileTab.Muted].map(v => { - return
setTab(v)}>{v}
- })} + {[ProfileTab.Notes, ProfileTab.Followers, ProfileTab.Follows, ProfileTab.Muted].map(renderTab)} + {isMe && renderTab(ProfileTab.Blocked)}
{tabContent()}