Surface unsent messages on the sublist notification badge too

This commit is contained in:
Michael Telatynski 2021-09-10 10:58:13 +01:00
parent bbe714257e
commit aff9be6120
3 changed files with 11 additions and 8 deletions

View file

@ -143,15 +143,16 @@ export default class NotificationBadge extends React.PureComponent<XOR<IProps, I
}); });
if (onClick) { if (onClick) {
let tooltip; let label: string;
let tooltip: JSX.Element;
if (showUnsentTooltip && this.state.showTooltip && notification.color === NotificationColor.Unsent) { if (showUnsentTooltip && this.state.showTooltip && notification.color === NotificationColor.Unsent) {
tooltip = ( label = _t("Message didn't send. Click for info.");
<Tooltip className="mx_RoleButton_tooltip" label={_t("Message didn't send. Click for info.")} /> tooltip = <Tooltip className="mx_RoleButton_tooltip" label={label} />;
);
} }
return ( return (
<AccessibleButton <AccessibleButton
aria-label={label}
{...props} {...props}
className={classes} className={classes}
onClick={onClick} onClick={onClick}

View file

@ -670,6 +670,7 @@ export default class RoomSublist extends React.Component<IProps, IState> {
onClick={this.onBadgeClick} onClick={this.onBadgeClick}
tabIndex={tabIndex} tabIndex={tabIndex}
aria-label={ariaLabel} aria-label={ariaLabel}
showUnsentTooltip={true}
/> />
); );

View file

@ -31,10 +31,6 @@ export class ListNotificationState extends NotificationState {
super(); super();
} }
public get symbol(): string {
return null; // This notification state doesn't support symbols
}
public setRooms(rooms: Room[]) { public setRooms(rooms: Room[]) {
// If we're only concerned about the tile count, don't bother setting up listeners. // If we're only concerned about the tile count, don't bother setting up listeners.
if (this.byTileCount) { if (this.byTileCount) {
@ -82,6 +78,7 @@ export class ListNotificationState extends NotificationState {
private calculateTotalState() { private calculateTotalState() {
const snapshot = this.snapshot(); const snapshot = this.snapshot();
this._symbol = null;
if (this.byTileCount) { if (this.byTileCount) {
this._color = NotificationColor.Red; this._color = NotificationColor.Red;
this._count = this.rooms.length; this._count = this.rooms.length;
@ -92,6 +89,10 @@ export class ListNotificationState extends NotificationState {
this._count += state.count; this._count += state.count;
this._color = Math.max(this.color, state.color); this._color = Math.max(this.color, state.color);
} }
if (this._color === NotificationColor.Unsent) {
this._symbol = "!";
}
} }
// finally, publish an update if needed // finally, publish an update if needed