Add unread indicator to the timelineCard header icon (#7156)

Co-authored-by: J. Ryan Stinnett <jryans@gmail.com>
Co-authored-by: Travis Ralston <travisr@matrix.org>
This commit is contained in:
Timo 2021-11-30 11:06:20 +01:00 committed by GitHub
parent 766d1ee3e8
commit 8905c5d2bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 92 additions and 33 deletions

View file

@ -39,6 +39,8 @@ import { SearchScope } from './SearchBar';
import { ContextMenuTooltipButton } from '../../structures/ContextMenu';
import RoomContextMenu from "../context_menus/RoomContextMenu";
import { contextMenuBelow } from './RoomTile';
import { RoomNotificationStateStore } from '../../../stores/notifications/RoomNotificationStateStore';
import { NOTIFICATION_STATE_UPDATE } from '../../../stores/notifications/NotificationState';
import { RightPanelPhases } from '../../../stores/RightPanelStorePhases';
export interface ISearchInfo {
@ -75,7 +77,8 @@ export default class RoomHeader extends React.Component<IProps, IState> {
constructor(props, context) {
super(props, context);
const notiStore = RoomNotificationStateStore.instance.getRoomState(props.room);
notiStore.on(NOTIFICATION_STATE_UPDATE, this.onNotificationUpdate);
this.state = {};
}
@ -89,6 +92,8 @@ export default class RoomHeader extends React.Component<IProps, IState> {
if (cli) {
cli.removeListener("RoomState.events", this.onRoomStateEvents);
}
const notiStore = RoomNotificationStateStore.instance.getRoomState(this.props.room);
notiStore.removeListener(NOTIFICATION_STATE_UPDATE, this.onNotificationUpdate);
}
private onRoomStateEvents = (event: MatrixEvent, state: RoomState) => {
@ -100,6 +105,10 @@ export default class RoomHeader extends React.Component<IProps, IState> {
this.rateLimitedUpdate();
};
private onNotificationUpdate = () => {
this.forceUpdate();
};
private rateLimitedUpdate = throttle(() => {
this.forceUpdate();
}, 500, { leading: true, trailing: true });