From 3c6fd586281693b07143d344856eb8873b1d360c Mon Sep 17 00:00:00 2001 From: David Baker Date: Fri, 15 Mar 2024 11:06:12 +0000 Subject: [PATCH] Replace forceCount prop with hideIfDot (#12344) This replaces the `forceCount` prop on room badge components with `hideIfDot` which hopefully gives a better idea of what it does, since forceCount did not really force a count. Also remove the prop where it was just passing the default value anyway. --- .../views/avatars/DecoratedRoomAvatar.tsx | 10 +++++++--- src/components/views/rooms/ExtraTile.tsx | 2 +- src/components/views/rooms/NotificationBadge.tsx | 15 ++++++++------- src/components/views/rooms/RoomBreadcrumbs.tsx | 2 +- src/components/views/rooms/RoomSublist.tsx | 2 +- src/components/views/rooms/RoomTile.tsx | 6 +----- src/components/views/spaces/SpaceTreeLevel.tsx | 1 - 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/components/views/avatars/DecoratedRoomAvatar.tsx b/src/components/views/avatars/DecoratedRoomAvatar.tsx index ed8afe7b61..5879dd3b1a 100644 --- a/src/components/views/avatars/DecoratedRoomAvatar.tsx +++ b/src/components/views/avatars/DecoratedRoomAvatar.tsx @@ -35,7 +35,11 @@ interface IProps { room: Room; size: string; displayBadge?: boolean; - forceCount?: boolean; + /** + * If true, show nothing if the notification would only cause a dot to be shown rather than + * a badge. That is: only display badges and not dots. Default: false. + */ + hideIfDot?: boolean; oobData?: IOOBData; viewAvatarOnClick?: boolean; tooltipProps?: { @@ -178,14 +182,14 @@ export default class DecoratedRoomAvatar extends React.PureComponent ); diff --git a/src/components/views/rooms/ExtraTile.tsx b/src/components/views/rooms/ExtraTile.tsx index 157bfc4d56..3bb3a21525 100644 --- a/src/components/views/rooms/ExtraTile.tsx +++ b/src/components/views/rooms/ExtraTile.tsx @@ -52,7 +52,7 @@ export default function ExtraTile({ let badge: JSX.Element | null = null; if (notificationState) { - badge = ; + badge = ; } let name = displayName; diff --git a/src/components/views/rooms/NotificationBadge.tsx b/src/components/views/rooms/NotificationBadge.tsx index d152ab6a62..d4f7ee5040 100644 --- a/src/components/views/rooms/NotificationBadge.tsx +++ b/src/components/views/rooms/NotificationBadge.tsx @@ -28,10 +28,10 @@ interface IProps { notification: NotificationState; /** - * If true, the badge will show a count if at all possible. This is typically - * used to override the user's preference for things like room sublists. + * If true, show nothing if the notification would only cause a dot to be shown rather than + * a badge. That is: only display badges and not dots. Default: false. */ - forceCount?: boolean; + hideIfDot?: boolean; /** * The room ID, if any, the badge represents. @@ -48,7 +48,7 @@ interface IClickableProps extends IProps, React.InputHTMLAttributes { } interface IState { - showCounts: boolean; // whether to show counts. Independent of props.forceCount + showCounts: boolean; // whether to show counts. } export default class NotificationBadge extends React.PureComponent, IState> { @@ -97,11 +97,12 @@ export default class NotificationBadge extends React.PureComponent = { diff --git a/src/components/views/rooms/RoomBreadcrumbs.tsx b/src/components/views/rooms/RoomBreadcrumbs.tsx index eca8da4624..cd31dbd8e7 100644 --- a/src/components/views/rooms/RoomBreadcrumbs.tsx +++ b/src/components/views/rooms/RoomBreadcrumbs.tsx @@ -61,7 +61,7 @@ const RoomBreadcrumbTile: React.FC<{ room: Room; onClick: (ev: ButtonEvent) => v room={room} size="32px" displayBadge={true} - forceCount={true} + hideIfDot={true} tooltipProps={{ tabIndex: isActive ? 0 : -1 }} /> diff --git a/src/components/views/rooms/RoomSublist.tsx b/src/components/views/rooms/RoomSublist.tsx index 4e84bee0be..c8ad9d4aca 100644 --- a/src/components/views/rooms/RoomSublist.tsx +++ b/src/components/views/rooms/RoomSublist.tsx @@ -657,7 +657,7 @@ export default class RoomSublist extends React.Component { const badge = ( { // aria-hidden because we summarise the unread count/highlight status in a manual aria-label below badge = ( ); } diff --git a/src/components/views/spaces/SpaceTreeLevel.tsx b/src/components/views/spaces/SpaceTreeLevel.tsx index c0b7170923..315cba3c1c 100644 --- a/src/components/views/spaces/SpaceTreeLevel.tsx +++ b/src/components/views/spaces/SpaceTreeLevel.tsx @@ -113,7 +113,6 @@ export const SpaceButton = ({