fix followed tag active tab highlighting

This commit is contained in:
Sam Samskies 2023-04-15 18:08:16 -05:00
parent 24b07e4a27
commit d314f8269d
No known key found for this signature in database
GPG Key ID: E3F697EE1B6EB156
1 changed files with 14 additions and 5 deletions

View File

@ -40,8 +40,22 @@ export default function RootPage() {
data: "/global",
},
};
const tagTabs = tags.item.map((t, idx) => {
return { text: `#${t}`, value: idx + 3, data: `/tag/${t}` };
});
const tabs = [RootTab.Posts, RootTab.PostsAndReplies, RootTab.Global, ...tagTabs];
const tab = useMemo(() => {
const pTab = location.pathname.split("/").slice(-1)[0];
if (location.pathname.startsWith("/tag")) {
const selectedTag = tagTabs.find(t => t.text.slice(1) === pTab);
if (selectedTag) {
return selectedTag;
}
}
switch (pTab) {
case "conversations": {
return RootTab.PostsAndReplies;
@ -64,11 +78,6 @@ export default function RootPage() {
}
}, [location]);
const tagTabs = tags.item.map((t, idx) => {
return { text: `#${t}`, value: idx + 3, data: `/tag/${t}` };
});
const tabs = [RootTab.Posts, RootTab.PostsAndReplies, RootTab.Global, ...tagTabs];
return (
<>
<div className="main-content">