From 42d265731f8e09e779597fa704f662cda06cf2a8 Mon Sep 17 00:00:00 2001 From: Gigi Date: Sat, 18 Oct 2025 09:12:22 +0200 Subject: [PATCH] feat: hide login button and user icon when logged out - Remove redundant login button from sidebar header - Hide profile avatar when no active account - Users can now only login through the main login screen - Logout button only shown when logged in - Clean up unused imports (useState, Accounts, faRightToBracket) --- src/components/SidebarHeader.tsx | 61 +++++++++----------------------- 1 file changed, 17 insertions(+), 44 deletions(-) diff --git a/src/components/SidebarHeader.tsx b/src/components/SidebarHeader.tsx index 4997621f..659d53f3 100644 --- a/src/components/SidebarHeader.tsx +++ b/src/components/SidebarHeader.tsx @@ -1,11 +1,10 @@ -import React, { useState } from 'react' +import React from 'react' import { useNavigate } from 'react-router-dom' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faChevronRight, faRightFromBracket, faRightToBracket, faUserCircle, faGear, faHome, faNewspaper, faTimes } from '@fortawesome/free-solid-svg-icons' +import { faChevronRight, faRightFromBracket, faUserCircle, faGear, faHome, faNewspaper, faTimes } from '@fortawesome/free-solid-svg-icons' import { Hooks } from 'applesauce-react' import { useEventModel } from 'applesauce-react/hooks' import { Models } from 'applesauce-core' -import { Accounts } from 'applesauce-accounts' import IconButton from './IconButton' interface SidebarHeaderProps { @@ -16,26 +15,10 @@ interface SidebarHeaderProps { } const SidebarHeader: React.FC = ({ onToggleCollapse, onLogout, onOpenSettings, isMobile = false }) => { - const [isConnecting, setIsConnecting] = useState(false) const navigate = useNavigate() const activeAccount = Hooks.useActiveAccount() - const accountManager = Hooks.useAccountManager() const profile = useEventModel(Models.ProfileModel, activeAccount ? [activeAccount.pubkey] : null) - const handleLogin = async () => { - try { - setIsConnecting(true) - const account = await Accounts.ExtensionAccount.fromExtension() - accountManager.addAccount(account) - accountManager.setActive(account) - } catch (error) { - console.error('Login failed:', error) - alert('Login failed. Please install a nostr browser extension and try again.\n\nIf you aren\'t on nostr yet, start here: https://nstart.me/') - } finally { - setIsConnecting(false) - } - } - const getProfileImage = () => { return profile?.picture || null } @@ -73,22 +56,20 @@ const SidebarHeader: React.FC = ({ onToggleCollapse, onLogou )}
-
navigate('/me') - : (isConnecting ? () => {} : handleLogin) - } - style={{ cursor: 'pointer' }} - > - {profileImage ? ( - {getUserDisplayName()} - ) : ( - - )} -
+ {activeAccount && ( +
navigate('/me')} + style={{ cursor: 'pointer' }} + > + {profileImage ? ( + {getUserDisplayName()} + ) : ( + + )} +
+ )} navigate('/')} @@ -110,7 +91,7 @@ const SidebarHeader: React.FC = ({ onToggleCollapse, onLogou ariaLabel="Settings" variant="ghost" /> - {activeAccount ? ( + {activeAccount && ( = ({ onToggleCollapse, onLogou ariaLabel="Logout" variant="ghost" /> - ) : ( - {} : handleLogin} - title={isConnecting ? "Connecting..." : "Login"} - ariaLabel="Login" - variant="ghost" - /> )}