forked from Kieran/snort
set initial tab name correctly
This commit is contained in:
parent
1e3a180150
commit
316b5578e8
@ -128,18 +128,21 @@ export function RootTabs({ base = "/" }) {
|
||||
tags: s.tags,
|
||||
preferences: s.appData.item.preferences,
|
||||
}));
|
||||
const [rootType, setRootType] = useState<RootTab>("following");
|
||||
|
||||
const menuItems = useMemo(() => rootTabItems(base, pubKey, tags), [base, pubKey, tags]);
|
||||
|
||||
const defaultTab = pubKey ? preferences.defaultRootTab ?? `${base}/notes` : `${base}/trending/notes`;
|
||||
const initialPathname = location.pathname === "/" ? defaultTab : location.pathname;
|
||||
const initialRootType = menuItems.find(a => a.path === initialPathname)?.tab || "following";
|
||||
|
||||
const [rootType, setRootType] = useState<RootTab>(initialRootType);
|
||||
|
||||
useEffect(() => {
|
||||
const defaultTab = pubKey ? preferences.defaultRootTab ?? `${base}/notes` : `${base}/trending/notes`;
|
||||
const pathname = location.pathname === "/" ? defaultTab : location.pathname;
|
||||
const currentTab = menuItems.find(a => a.path === pathname)?.tab;
|
||||
if (currentTab) {
|
||||
const currentTab = menuItems.find(a => a.path === location.pathname)?.tab;
|
||||
if (currentTab && currentTab !== rootType) {
|
||||
setRootType(currentTab);
|
||||
}
|
||||
}, [location, menuItems]);
|
||||
}, [location, menuItems, rootType]);
|
||||
|
||||
function currentMenuItem() {
|
||||
if (location.pathname.startsWith(`${base}/t/`)) {
|
||||
|
Loading…
Reference in New Issue
Block a user