Merge pull request #516 from v0l/fix-followed-tag-active-tab-highlighting

fix followed tag active tab highlighting
This commit is contained in:
Kieran 2023-04-17 10:00:29 +01:00 committed by GitHub
commit 6f292a9689
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 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">

View File

@ -364,4 +364,4 @@
"zjJZBd": "You're ready!",
"zonsdq": "Failed to load LNURL service",
"zvCDao": "Automatically show latest notes"
}
}