2020-07-01 01:24:46 +03:00
|
|
|
/*
|
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import { Room } from "matrix-js-sdk/src/models/room";
|
|
|
|
|
|
|
|
import { TagID } from '../../../stores/room-list/models';
|
|
|
|
import RoomAvatar from "./RoomAvatar";
|
|
|
|
import RoomTileIcon from "../rooms/RoomTileIcon";
|
2020-07-02 22:28:06 +03:00
|
|
|
import NotificationBadge from '../rooms/NotificationBadge';
|
2020-07-09 04:26:25 +03:00
|
|
|
import { RoomNotificationStateStore } from "../../../stores/notifications/RoomNotificationStateStore";
|
|
|
|
import { NotificationState } from "../../../stores/notifications/NotificationState";
|
2020-07-01 01:24:46 +03:00
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
room: Room;
|
|
|
|
avatarSize: number;
|
|
|
|
tag: TagID;
|
|
|
|
displayBadge?: boolean;
|
|
|
|
forceCount?: boolean;
|
2020-07-14 01:56:25 +03:00
|
|
|
oobData?: object;
|
|
|
|
viewAvatarOnClick?: boolean;
|
2020-07-01 01:24:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
interface IState {
|
2020-07-09 04:26:25 +03:00
|
|
|
notificationState?: NotificationState;
|
2020-07-01 01:24:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export default class DecoratedRoomAvatar extends React.PureComponent<IProps, IState> {
|
|
|
|
|
|
|
|
constructor(props: IProps) {
|
|
|
|
super(props);
|
|
|
|
|
|
|
|
this.state = {
|
2020-07-09 04:26:25 +03:00
|
|
|
notificationState: RoomNotificationStateStore.instance.getRoomState(this.props.room, this.props.tag),
|
2020-07-01 01:39:25 +03:00
|
|
|
};
|
2020-07-01 01:24:46 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public render(): React.ReactNode {
|
|
|
|
let badge: React.ReactNode;
|
|
|
|
if (this.props.displayBadge) {
|
|
|
|
badge = <NotificationBadge
|
|
|
|
notification={this.state.notificationState}
|
|
|
|
forceCount={this.props.forceCount}
|
|
|
|
roomId={this.props.room.roomId}
|
|
|
|
/>;
|
|
|
|
}
|
|
|
|
|
|
|
|
return <div className="mx_DecoratedRoomAvatar">
|
2020-07-14 01:56:25 +03:00
|
|
|
<RoomAvatar
|
|
|
|
room={this.props.room}
|
|
|
|
width={this.props.avatarSize}
|
|
|
|
height={this.props.avatarSize}
|
|
|
|
oobData={this.props.oobData}
|
|
|
|
viewAvatarOnClick={this.props.viewAvatarOnClick}
|
|
|
|
/>
|
2020-07-01 01:35:59 +03:00
|
|
|
<RoomTileIcon room={this.props.room} tag={this.props.tag} />
|
2020-07-01 01:24:46 +03:00
|
|
|
{badge}
|
2020-07-01 01:39:25 +03:00
|
|
|
</div>;
|
2020-07-01 01:24:46 +03:00
|
|
|
}
|
2020-07-02 22:28:06 +03:00
|
|
|
}
|