show correct feed name when not logged in
Some checks are pending
continuous-integration/drone/push Build is running
Some checks are pending
continuous-integration/drone/push Build is running
This commit is contained in:
parent
c9e84ccbbf
commit
8bbd473b89
@ -116,16 +116,21 @@ export function rootTabItems(base: string, pubKey: string | undefined, tags: New
|
|||||||
return menuItems;
|
return menuItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function RootTabs({ base }: { base?: string }) {
|
export function RootTabs({ base = "/" }) {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const location = useLocation();
|
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 [rootType, setRootType] = useState<RootTab>("following");
|
||||||
|
|
||||||
const menuItems = useMemo(() => rootTabItems(base, pubKey, tags), [base, pubKey, tags]);
|
const menuItems = useMemo(() => rootTabItems(base, pubKey, tags), [base, pubKey, tags]);
|
||||||
|
|
||||||
useEffect(() => {
|
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;
|
const currentTab = menuItems.find(a => a.path === pathname)?.tab;
|
||||||
if (currentTab) {
|
if (currentTab) {
|
||||||
setRootType(currentTab);
|
setRootType(currentTab);
|
||||||
|
Loading…
Reference in New Issue
Block a user