ProfileMenuButton: fix the lost profile info
All checks were successful
/ depoly (push) Successful in 1m19s

This commit is contained in:
thislight 2024-11-04 18:21:22 +08:00
parent 6705b754d1
commit 9d720d31b4
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E

View file

@ -25,8 +25,15 @@ import { A } from "@solidjs/router";
const ProfileMenuButton: ParentComponent<{ const ProfileMenuButton: ParentComponent<{
profile?: { profile?: {
account: { site: string }; account: {
inf?: { displayName: string; avatar: string; username: string; id: string }; site: string;
inf?: {
displayName: string;
avatar: string;
username: string;
id: string;
};
};
}; };
onClick?: () => void; onClick?: () => void;
onClose?: () => void; onClose?: () => void;
@ -44,6 +51,8 @@ const ProfileMenuButton: ParentComponent<{
props.onClick?.(); props.onClick?.();
}; };
const inf = () => props.profile?.account.inf
const onClose = () => { const onClose = () => {
props.onClick?.(); props.onClick?.();
setAnchor(null); setAnchor(null);
@ -60,8 +69,8 @@ const ProfileMenuButton: ParentComponent<{
aria-expanded={open() ? "true" : undefined} aria-expanded={open() ? "true" : undefined}
> >
<Avatar <Avatar
alt={`${props.profile?.inf?.displayName}'s avatar`} alt={`${inf()?.displayName}'s avatar`}
src={props.profile?.inf?.avatar} src={inf()?.avatar}
></Avatar> ></Avatar>
</ButtonBase> </ButtonBase>
<Menu <Menu
@ -86,31 +95,31 @@ const ProfileMenuButton: ParentComponent<{
> >
<MenuItem <MenuItem
component={A} component={A}
href={`/${encodeURIComponent(`${props.profile?.inf?.username}@${props.profile?.account.site}`)}/profile/${props.profile?.inf?.id}`} href={`/${encodeURIComponent(`${inf()?.username}@${props.profile?.account.site}`)}/profile/${inf()?.id}`}
disabled={!props.profile} disabled={!props.profile}
> >
<ListItemAvatar> <ListItemAvatar>
<Avatar src={props.profile?.inf?.avatar}></Avatar> <Avatar src={inf()?.avatar}></Avatar>
</ListItemAvatar> </ListItemAvatar>
<ListItemText <ListItemText
primary={props.profile?.inf?.displayName} primary={inf()?.displayName}
secondary={`@${props.profile?.inf?.username}`} secondary={`@${inf()?.username}`}
></ListItemText> ></ListItemText>
</MenuItem> </MenuItem>
<MenuItem> <MenuItem disabled>
<ListItemIcon> <ListItemIcon>
<BookmarkIcon /> <BookmarkIcon />
</ListItemIcon> </ListItemIcon>
<ListItemText>Bookmarks</ListItemText> <ListItemText>Bookmarks</ListItemText>
</MenuItem> </MenuItem>
<MenuItem> <MenuItem disabled>
<ListItemIcon> <ListItemIcon>
<LikeIcon /> <LikeIcon />
</ListItemIcon> </ListItemIcon>
<ListItemText>Likes</ListItemText> <ListItemText>Likes</ListItemText>
</MenuItem> </MenuItem>
<MenuItem> <MenuItem disabled>
<ListItemIcon> <ListItemIcon>
<ListIcon /> <ListIcon />
</ListItemIcon> </ListItemIcon>