Fix missing metaspace notification badges (#11269)
* Fix missing metaspace notification badges
* Simplify conditional types
(cherry picked from commit cdffd1ca1f
)
This commit is contained in:
parent
a67427e6ca
commit
d38819ce9a
3 changed files with 78 additions and 6 deletions
|
@ -65,7 +65,7 @@ interface IButtonProps extends Omit<ComponentProps<typeof AccessibleTooltipButto
|
|||
|
||||
export const SpaceButton: React.FC<IButtonProps> = ({
|
||||
space,
|
||||
spaceKey,
|
||||
spaceKey: _spaceKey,
|
||||
className,
|
||||
selected,
|
||||
label,
|
||||
|
@ -82,6 +82,8 @@ export const SpaceButton: React.FC<IButtonProps> = ({
|
|||
const [onFocus, isActive] = useRovingTabIndex(handle);
|
||||
const tabIndex = isActive ? 0 : -1;
|
||||
|
||||
const spaceKey = _spaceKey ?? space?.roomId;
|
||||
|
||||
let avatar = (
|
||||
<div className="mx_SpaceButton_avatarPlaceholder">
|
||||
<div className="mx_SpaceButton_icon" />
|
||||
|
@ -92,16 +94,16 @@ export const SpaceButton: React.FC<IButtonProps> = ({
|
|||
}
|
||||
|
||||
let notifBadge;
|
||||
if (space && notificationState) {
|
||||
if (spaceKey && notificationState) {
|
||||
let ariaLabel = _t("Jump to first unread room.");
|
||||
if (space.getMyMembership() === "invite") {
|
||||
if (space?.getMyMembership() === "invite") {
|
||||
ariaLabel = _t("Jump to first invite.");
|
||||
}
|
||||
|
||||
const jumpToNotification = (ev: MouseEvent): void => {
|
||||
ev.stopPropagation();
|
||||
ev.preventDefault();
|
||||
SpaceStore.instance.setActiveRoomInSpace(spaceKey ?? space.roomId);
|
||||
SpaceStore.instance.setActiveRoomInSpace(spaceKey);
|
||||
};
|
||||
|
||||
notifBadge = (
|
||||
|
@ -132,7 +134,9 @@ export const SpaceButton: React.FC<IButtonProps> = ({
|
|||
const viewSpaceHome = (): void =>
|
||||
// space is set here because of the assignment condition of onClick
|
||||
defaultDispatcher.dispatch({ action: Action.ViewRoom, room_id: space!.roomId });
|
||||
const activateSpace = (): void => SpaceStore.instance.setActiveSpace(spaceKey ?? space?.roomId ?? "");
|
||||
const activateSpace = (): void => {
|
||||
if (spaceKey) SpaceStore.instance.setActiveSpace(spaceKey);
|
||||
};
|
||||
const onClick = props.onClick ?? (selected && space ? viewSpaceHome : activateSpace);
|
||||
|
||||
return (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue