Iterate EntityTile
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
e25940cbdd
commit
298e505381
1 changed files with 10 additions and 9 deletions
|
@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import React, { createRef } from 'react';
|
import React from 'react';
|
||||||
import AccessibleButton from '../elements/AccessibleButton';
|
import AccessibleButton from '../elements/AccessibleButton';
|
||||||
import { _td } from '../../../languageHandler';
|
import { _td } from '../../../languageHandler';
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
|
@ -25,7 +25,12 @@ import { replaceableComponent } from "../../../utils/replaceableComponent";
|
||||||
import BaseAvatar from '../avatars/BaseAvatar';
|
import BaseAvatar from '../avatars/BaseAvatar';
|
||||||
import PresenceLabel from "./PresenceLabel";
|
import PresenceLabel from "./PresenceLabel";
|
||||||
|
|
||||||
const PowerLabel: Record<string, string> = {
|
enum PowerStatus {
|
||||||
|
Admin = "admin",
|
||||||
|
Moderator = "moderator",
|
||||||
|
}
|
||||||
|
|
||||||
|
const PowerLabel: Record<PowerStatus, string> = {
|
||||||
"admin": _td("Admin"),
|
"admin": _td("Admin"),
|
||||||
"moderator": _td("Mod"),
|
"moderator": _td("Mod"),
|
||||||
}
|
}
|
||||||
|
@ -36,7 +41,7 @@ const PRESENCE_CLASS = {
|
||||||
"unavailable": "mx_EntityTile_unavailable",
|
"unavailable": "mx_EntityTile_unavailable",
|
||||||
};
|
};
|
||||||
|
|
||||||
function presenceClassForMember(presenceState: string, lastActiveAgo: number, showPresence: boolean) {
|
function presenceClassForMember(presenceState: string, lastActiveAgo: number, showPresence: boolean): string {
|
||||||
if (showPresence === false) {
|
if (showPresence === false) {
|
||||||
return 'mx_EntityTile_online_beenactive';
|
return 'mx_EntityTile_online_beenactive';
|
||||||
}
|
}
|
||||||
|
@ -66,13 +71,12 @@ interface IProps {
|
||||||
presenceLastTs?: number,
|
presenceLastTs?: number,
|
||||||
presenceCurrentlyActive?: boolean,
|
presenceCurrentlyActive?: boolean,
|
||||||
showInviteButton?: boolean,
|
showInviteButton?: boolean,
|
||||||
shouldComponentUpdate?(nextProps: IProps, nextState: IState): boolean,
|
|
||||||
onClick?(): void,
|
onClick?(): void,
|
||||||
suppressOnHover?: boolean,
|
suppressOnHover?: boolean,
|
||||||
showPresence?: boolean,
|
showPresence?: boolean,
|
||||||
subtextLabel?: string,
|
subtextLabel?: string,
|
||||||
e2eStatus?: string,
|
e2eStatus?: string,
|
||||||
powerStatus?: string,
|
powerStatus?: PowerStatus,
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
|
@ -82,7 +86,6 @@ interface IState {
|
||||||
@replaceableComponent("views.rooms.EntityTile")
|
@replaceableComponent("views.rooms.EntityTile")
|
||||||
export default class EntityTile extends React.Component<IProps, IState> {
|
export default class EntityTile extends React.Component<IProps, IState> {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
shouldComponentUpdate: (nextProps: IProps, nextState: IState) => { return true; },
|
|
||||||
onClick: () => {},
|
onClick: () => {},
|
||||||
presenceState: "offline",
|
presenceState: "offline",
|
||||||
presenceLastActiveAgo: 0,
|
presenceLastActiveAgo: 0,
|
||||||
|
@ -91,7 +94,6 @@ export default class EntityTile extends React.Component<IProps, IState> {
|
||||||
suppressOnHover: false,
|
suppressOnHover: false,
|
||||||
showPresence: true,
|
showPresence: true,
|
||||||
};
|
};
|
||||||
private container = createRef<HTMLDivElement>();
|
|
||||||
|
|
||||||
constructor(props: IProps) {
|
constructor(props: IProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
@ -103,7 +105,6 @@ export default class EntityTile extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps: IProps, nextState: IState) {
|
shouldComponentUpdate(nextProps: IProps, nextState: IState) {
|
||||||
if (this.state.hover !== nextState.hover) return true;
|
if (this.state.hover !== nextState.hover) return true;
|
||||||
return this.props.shouldComponentUpdate(nextProps, nextState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -184,7 +185,7 @@ export default class EntityTile extends React.Component<IProps, IState> {
|
||||||
|
|
||||||
// The wrapping div is required to make the magic mouse listener work, for some reason.
|
// The wrapping div is required to make the magic mouse listener work, for some reason.
|
||||||
return (
|
return (
|
||||||
<div ref={this.container} >
|
<div>
|
||||||
<AccessibleButton
|
<AccessibleButton
|
||||||
className={classNames(mainClassNames)}
|
className={classNames(mainClassNames)}
|
||||||
title={this.props.title}
|
title={this.props.title}
|
||||||
|
|
Loading…
Reference in a new issue