show correct feed name when not logged in
Some checks are pending
continuous-integration/drone/push Build is running

This commit is contained in:
Martti Malmi 2023-12-07 10:11:41 +02:00
parent c9e84ccbbf
commit 8bbd473b89

View File

@ -116,16 +116,21 @@ export function rootTabItems(base: string, pubKey: string | undefined, tags: New
return menuItems;
}
export function RootTabs({ base }: { base?: string }) {
export function RootTabs({ base = "/" }) {
const navigate = useNavigate();
const location = useLocation();
const { publicKey: pubKey, tags } = useLogin();
const { publicKey: pubKey, tags, preferences } = useLogin(s => ({
publicKey: s.publicKey,
tags: s.tags,
preferences: s.appData.item.preferences,
}));
const [rootType, setRootType] = useState<RootTab>("following");
const menuItems = useMemo(() => rootTabItems(base, pubKey, tags), [base, pubKey, tags]);
useEffect(() => {
const pathname = location.pathname === "/" ? `${base}/notes` : location.pathname;
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) {
setRootType(currentTab);