Apply prettier formatting

This commit is contained in:
Michael Weimann 2022-12-12 12:24:14 +01:00
parent 1cac306093
commit 526645c791
No known key found for this signature in database
GPG key ID: 53F535A266BB9584
1576 changed files with 65385 additions and 62478 deletions

View file

@ -16,13 +16,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React from 'react';
import React from "react";
import classNames from "classnames";
import AccessibleButton from '../elements/AccessibleButton';
import { _t, _td } from '../../../languageHandler';
import E2EIcon, { E2EState } from './E2EIcon';
import BaseAvatar from '../avatars/BaseAvatar';
import AccessibleButton from "../elements/AccessibleButton";
import { _t, _td } from "../../../languageHandler";
import E2EIcon, { E2EState } from "./E2EIcon";
import BaseAvatar from "../avatars/BaseAvatar";
import PresenceLabel from "./PresenceLabel";
export enum PowerStatus {
@ -36,28 +36,28 @@ const PowerLabel: Record<PowerStatus, string> = {
};
const PRESENCE_CLASS = {
"offline": "mx_EntityTile_offline",
"online": "mx_EntityTile_online",
"unavailable": "mx_EntityTile_unavailable",
offline: "mx_EntityTile_offline",
online: "mx_EntityTile_online",
unavailable: "mx_EntityTile_unavailable",
};
function presenceClassForMember(presenceState: string, lastActiveAgo: number, showPresence: boolean): string {
if (showPresence === false) {
return 'mx_EntityTile_online_beenactive';
return "mx_EntityTile_online_beenactive";
}
// offline is split into two categories depending on whether we have
// a last_active_ago for them.
if (presenceState === 'offline') {
if (presenceState === "offline") {
if (lastActiveAgo) {
return PRESENCE_CLASS['offline'] + '_beenactive';
return PRESENCE_CLASS["offline"] + "_beenactive";
} else {
return PRESENCE_CLASS['offline'] + '_neveractive';
return PRESENCE_CLASS["offline"] + "_neveractive";
}
} else if (presenceState) {
return PRESENCE_CLASS[presenceState];
} else {
return PRESENCE_CLASS['offline'] + '_neveractive';
return PRESENCE_CLASS["offline"] + "_neveractive";
}
}
@ -105,13 +105,15 @@ export default class EntityTile extends React.PureComponent<IProps, IState> {
render() {
const mainClassNames = {
"mx_EntityTile": true,
"mx_EntityTile_noHover": this.props.suppressOnHover,
mx_EntityTile: true,
mx_EntityTile_noHover: this.props.suppressOnHover,
};
if (this.props.className) mainClassNames[this.props.className] = true;
const presenceClass = presenceClassForMember(
this.props.presenceState, this.props.presenceLastActiveAgo, this.props.showPresence,
this.props.presenceState,
this.props.presenceLastActiveAgo,
this.props.showPresence,
);
mainClassNames[presenceClass] = true;
@ -119,39 +121,38 @@ export default class EntityTile extends React.PureComponent<IProps, IState> {
const name = this.props.nameJSX || this.props.name;
if (!this.props.suppressOnHover) {
const activeAgo = this.props.presenceLastActiveAgo ?
(Date.now() - (this.props.presenceLastTs - this.props.presenceLastActiveAgo)) : -1;
const activeAgo = this.props.presenceLastActiveAgo
? Date.now() - (this.props.presenceLastTs - this.props.presenceLastActiveAgo)
: -1;
let presenceLabel = null;
if (this.props.showPresence) {
presenceLabel = <PresenceLabel activeAgo={activeAgo}
currentlyActive={this.props.presenceCurrentlyActive}
presenceState={this.props.presenceState} />;
presenceLabel = (
<PresenceLabel
activeAgo={activeAgo}
currentlyActive={this.props.presenceCurrentlyActive}
presenceState={this.props.presenceState}
/>
);
}
if (this.props.subtextLabel) {
presenceLabel = <span className="mx_EntityTile_subtext">{ this.props.subtextLabel }</span>;
presenceLabel = <span className="mx_EntityTile_subtext">{this.props.subtextLabel}</span>;
}
nameEl = (
<div className="mx_EntityTile_details">
<div className="mx_EntityTile_name">
{ name }
</div>
{ presenceLabel }
<div className="mx_EntityTile_name">{name}</div>
{presenceLabel}
</div>
);
} else if (this.props.subtextLabel) {
nameEl = (
<div className="mx_EntityTile_details">
<div className="mx_EntityTile_name">
{ name }
</div>
<span className="mx_EntityTile_subtext">{ this.props.subtextLabel }</span>
<div className="mx_EntityTile_name">{name}</div>
<span className="mx_EntityTile_subtext">{this.props.subtextLabel}</span>
</div>
);
} else {
nameEl = (
<div className="mx_EntityTile_name">{ name }</div>
);
nameEl = <div className="mx_EntityTile_name">{name}</div>;
}
let inviteButton;
@ -167,7 +168,7 @@ export default class EntityTile extends React.PureComponent<IProps, IState> {
const powerStatus = this.props.powerStatus;
if (powerStatus) {
const powerText = _t(PowerLabel[powerStatus]);
powerLabel = <div className="mx_EntityTile_power">{ powerText }</div>;
powerLabel = <div className="mx_EntityTile_power">{powerText}</div>;
}
let e2eIcon;
@ -176,8 +177,9 @@ export default class EntityTile extends React.PureComponent<IProps, IState> {
e2eIcon = <E2EIcon status={e2eStatus} isUser={true} bordered={true} />;
}
const av = this.props.avatarJsx ||
<BaseAvatar name={this.props.name} width={36} height={36} aria-hidden="true" />;
const av = this.props.avatarJsx || (
<BaseAvatar name={this.props.name} width={36} height={36} aria-hidden="true" />
);
// The wrapping div is required to make the magic mouse listener work, for some reason.
return (
@ -188,12 +190,12 @@ export default class EntityTile extends React.PureComponent<IProps, IState> {
onClick={this.props.onClick}
>
<div className="mx_EntityTile_avatar">
{ av }
{ e2eIcon }
{av}
{e2eIcon}
</div>
{ nameEl }
{ powerLabel }
{ inviteButton }
{nameEl}
{powerLabel}
{inviteButton}
</AccessibleButton>
</div>
);