diff options
author | Eric Bailey <git@esb.lol> | 2023-11-09 20:35:17 -0600 |
---|---|---|
committer | Eric Bailey <git@esb.lol> | 2023-11-09 20:35:17 -0600 |
commit | ab878ba9a6afaa57805aeab988b01c5b47bc9286 (patch) | |
tree | 266f68581a5d237b0d22b4b94fb92e0e45c0993b /src/view/shell/desktop/LeftNav.tsx | |
parent | 487d871cfd89948f4db9944c4bb414d268a56537 (diff) | |
download | voidsky-ab878ba9a6afaa57805aeab988b01c5b47bc9286.tar.zst |
Web login/signup and shell
Diffstat (limited to 'src/view/shell/desktop/LeftNav.tsx')
-rw-r--r-- | src/view/shell/desktop/LeftNav.tsx | 63 |
1 files changed, 37 insertions, 26 deletions
diff --git a/src/view/shell/desktop/LeftNav.tsx b/src/view/shell/desktop/LeftNav.tsx index b85823b6f..3a0c0c95d 100644 --- a/src/view/shell/desktop/LeftNav.tsx +++ b/src/view/shell/desktop/LeftNav.tsx @@ -41,18 +41,31 @@ import {router} from '../../../routes' import {makeProfileLink} from 'lib/routes/links' import {useLingui} from '@lingui/react' import {Trans, msg} from '@lingui/macro' +import {useGetProfile} from '#/data/useGetProfile' +import {useSession} from '#/state/session' const ProfileCard = observer(function ProfileCardImpl() { - const store = useStores() + const {currentAccount} = useSession() + const { + isLoading, + isError, + data: profile, + } = useGetProfile({did: currentAccount!.did}) const {isDesktop} = useWebMediaQueries() const size = 48 - return store.me.handle ? ( + + if (isError || !profile || !currentAccount) return null + + return !isLoading ? ( <Link - href={makeProfileLink(store.me)} + href={makeProfileLink({ + did: currentAccount.did, + handle: currentAccount.handle, + })} style={[styles.profileCard, !isDesktop && styles.profileCardTablet]} title="My Profile" asAnchor> - <UserAvatar avatar={store.me.avatar} size={size} /> + <UserAvatar avatar={profile.avatar} size={size} /> </Link> ) : ( <View style={[styles.profileCard, !isDesktop && styles.profileCardTablet]}> @@ -255,7 +268,7 @@ export const DesktopLeftNav = observer(function DesktopLeftNav() { pal.view, pal.border, ]}> - {store.session.hasSession && <ProfileCard />} + <ProfileCard /> <BackBtn /> <NavItem href="/" @@ -360,26 +373,24 @@ export const DesktopLeftNav = observer(function DesktopLeftNav() { } label="Moderation" /> - {store.session.hasSession && ( - <NavItem - href={makeProfileLink(store.me)} - icon={ - <UserIcon - strokeWidth={1.75} - size={isDesktop ? 28 : 30} - style={pal.text} - /> - } - iconFilled={ - <UserIconSolid - strokeWidth={1.75} - size={isDesktop ? 28 : 30} - style={pal.text} - /> - } - label="Profile" - /> - )} + <NavItem + href={makeProfileLink(store.me)} + icon={ + <UserIcon + strokeWidth={1.75} + size={isDesktop ? 28 : 30} + style={pal.text} + /> + } + iconFilled={ + <UserIconSolid + strokeWidth={1.75} + size={isDesktop ? 28 : 30} + style={pal.text} + /> + } + label="Profile" + /> <NavItem href="/settings" icon={ @@ -398,7 +409,7 @@ export const DesktopLeftNav = observer(function DesktopLeftNav() { } label="Settings" /> - {store.session.hasSession && <ComposeBtn />} + <ComposeBtn /> </View> ) }) |