From 8bbd473b89795003f7e17f65c23d4f25a219b370 Mon Sep 17 00:00:00 2001 From: Martti Malmi Date: Thu, 7 Dec 2023 10:11:41 +0200 Subject: [PATCH] show correct feed name when not logged in --- packages/app/src/Element/Feed/RootTabs.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/app/src/Element/Feed/RootTabs.tsx b/packages/app/src/Element/Feed/RootTabs.tsx index 4ef3bcaa..34117cbe 100644 --- a/packages/app/src/Element/Feed/RootTabs.tsx +++ b/packages/app/src/Element/Feed/RootTabs.tsx @@ -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("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);