Move all the RED_EXCLAMATION badges to a single definition

This commit is contained in:
Travis Ralston 2021-04-21 16:43:25 -06:00
parent 9227618b42
commit 4be9c51dad
5 changed files with 7 additions and 11 deletions

View file

@ -25,7 +25,6 @@ import {Action} from "../../dispatcher/actions";
import {replaceableComponent} from "../../utils/replaceableComponent"; import {replaceableComponent} from "../../utils/replaceableComponent";
import {EventStatus} from "matrix-js-sdk/src/models/event"; import {EventStatus} from "matrix-js-sdk/src/models/event";
import NotificationBadge from "../views/rooms/NotificationBadge"; import NotificationBadge from "../views/rooms/NotificationBadge";
import {NotificationColor} from "../../stores/notifications/NotificationColor";
import {StaticNotificationState} from "../../stores/notifications/StaticNotificationState"; import {StaticNotificationState} from "../../stores/notifications/StaticNotificationState";
import AccessibleButton from "../views/elements/AccessibleButton"; import AccessibleButton from "../views/elements/AccessibleButton";
import InlineSpinner from "../views/elements/InlineSpinner"; import InlineSpinner from "../views/elements/InlineSpinner";
@ -236,7 +235,7 @@ export default class RoomStatusBar extends React.Component {
<div role="alert"> <div role="alert">
<div className="mx_RoomStatusBar_unsentBadge"> <div className="mx_RoomStatusBar_unsentBadge">
<NotificationBadge <NotificationBadge
notification={StaticNotificationState.forSymbol("!", NotificationColor.Red)} notification={StaticNotificationState.RED_EXCLAMATION}
/> />
</div> </div>
<div> <div>

View file

@ -41,7 +41,6 @@ import {objectHasDiff} from "../../../utils/objects";
import {replaceableComponent} from "../../../utils/replaceableComponent"; import {replaceableComponent} from "../../../utils/replaceableComponent";
import Tooltip from "../elements/Tooltip"; import Tooltip from "../elements/Tooltip";
import {StaticNotificationState} from "../../../stores/notifications/StaticNotificationState"; import {StaticNotificationState} from "../../../stores/notifications/StaticNotificationState";
import {NotificationColor} from "../../../stores/notifications/NotificationColor";
import NotificationBadge from "./NotificationBadge"; import NotificationBadge from "./NotificationBadge";
const eventTileTypes = { const eventTileTypes = {
@ -1264,7 +1263,7 @@ class SentReceipt extends React.PureComponent<ISentReceiptProps, ISentReceiptSta
let nonCssBadge = null; let nonCssBadge = null;
if (isFailed) { if (isFailed) {
nonCssBadge = <NotificationBadge nonCssBadge = <NotificationBadge
notification={StaticNotificationState.forSymbol("!", NotificationColor.Red)} notification={StaticNotificationState.RED_EXCLAMATION}
/>; />;
} }

View file

@ -1,7 +1,5 @@
/* /*
Copyright 2015, 2016 OpenMarket Ltd Copyright 2015-2018, 2020, 2021 The Matrix.org Foundation C.I.C.
Copyright 2017, 2018 Vector Creations Ltd
Copyright 2020 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -37,7 +35,6 @@ import { MatrixClientPeg } from "../../../MatrixClientPeg";
import GroupAvatar from "../avatars/GroupAvatar"; import GroupAvatar from "../avatars/GroupAvatar";
import ExtraTile from "./ExtraTile"; import ExtraTile from "./ExtraTile";
import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState"; import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState";
import { NotificationColor } from "../../../stores/notifications/NotificationColor";
import { Action } from "../../../dispatcher/actions"; import { Action } from "../../../dispatcher/actions";
import { ViewRoomDeltaPayload } from "../../../dispatcher/payloads/ViewRoomDeltaPayload"; import { ViewRoomDeltaPayload } from "../../../dispatcher/payloads/ViewRoomDeltaPayload";
import { RoomNotificationStateStore } from "../../../stores/notifications/RoomNotificationStateStore"; import { RoomNotificationStateStore } from "../../../stores/notifications/RoomNotificationStateStore";
@ -492,7 +489,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
isSelected={false} isSelected={false}
displayName={g.name} displayName={g.name}
avatar={avatar} avatar={avatar}
notificationState={StaticNotificationState.forSymbol("!", NotificationColor.Red)} notificationState={StaticNotificationState.RED_EXCLAMATION}
onClick={openGroup} onClick={openGroup}
key={`temporaryGroupTile_${g.groupId}`} key={`temporaryGroupTile_${g.groupId}`}
/> />

View file

@ -53,7 +53,6 @@ import { CommunityPrototypeStore, IRoomProfile } from "../../../stores/Community
import { replaceableComponent } from "../../../utils/replaceableComponent"; import { replaceableComponent } from "../../../utils/replaceableComponent";
import { getUnsentMessages } from "../../structures/RoomStatusBar"; import { getUnsentMessages } from "../../structures/RoomStatusBar";
import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState"; import { StaticNotificationState } from "../../../stores/notifications/StaticNotificationState";
import { NotificationColor } from "../../../stores/notifications/NotificationColor";
interface IProps { interface IProps {
room: Room; room: Room;
@ -576,7 +575,7 @@ export default class RoomTile extends React.PureComponent<IProps, IState> {
badge = ( badge = (
<div className="mx_RoomTile_badgeContainer" aria-hidden="true"> <div className="mx_RoomTile_badgeContainer" aria-hidden="true">
<NotificationBadge <NotificationBadge
notification={StaticNotificationState.forSymbol("!", NotificationColor.Red)} notification={StaticNotificationState.RED_EXCLAMATION}
forceCount={false} forceCount={false}
roomId={this.props.room.roomId} roomId={this.props.room.roomId}
/> />

View file

@ -18,6 +18,8 @@ import { NotificationColor } from "./NotificationColor";
import { NotificationState } from "./NotificationState"; import { NotificationState } from "./NotificationState";
export class StaticNotificationState extends NotificationState { export class StaticNotificationState extends NotificationState {
public static readonly RED_EXCLAMATION = StaticNotificationState.forSymbol("!", NotificationColor.Red);
constructor(symbol: string, count: number, color: NotificationColor) { constructor(symbol: string, count: number, color: NotificationColor) {
super(); super();
this._symbol = symbol; this._symbol = symbol;