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

@ -14,23 +14,23 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React, { createRef } from 'react';
import React, { createRef } from "react";
import { logger } from "matrix-js-sdk/src/logger";
import { _t } from "../../../languageHandler";
import { MatrixClientPeg } from "../../../MatrixClientPeg";
import Field from "../elements/Field";
import { getHostingLink } from '../../../utils/HostingLink';
import { getHostingLink } from "../../../utils/HostingLink";
import { OwnProfileStore } from "../../../stores/OwnProfileStore";
import Modal from "../../../Modal";
import ErrorDialog from "../dialogs/ErrorDialog";
import { mediaFromMxc } from "../../../customisations/Media";
import AccessibleButton from '../elements/AccessibleButton';
import AvatarSetting from './AvatarSetting';
import ExternalLink from '../elements/ExternalLink';
import UserIdentifierCustomisations from '../../../customisations/UserIdentifier';
import AccessibleButton from "../elements/AccessibleButton";
import AvatarSetting from "./AvatarSetting";
import ExternalLink from "../elements/ExternalLink";
import UserIdentifierCustomisations from "../../../customisations/UserIdentifier";
import { chromeFileInputFix } from "../../../utils/BrowserWorkarounds";
import PosthogTrackers from '../../../PosthogTrackers';
import PosthogTrackers from "../../../PosthogTrackers";
interface IState {
userId?: string;
@ -110,7 +110,8 @@ export default class ProfileSettings extends React.Component<{}, IState> {
if (this.state.avatarFile) {
logger.log(
`Uploading new avatar, ${this.state.avatarFile.name} of type ${this.state.avatarFile.type},` +
` (${this.state.avatarFile.size}) bytes`);
` (${this.state.avatarFile.size}) bytes`,
);
const { content_uri: uri } = await client.uploadContent(this.state.avatarFile);
await client.setAvatarUrl(uri);
newState.avatarUrl = mediaFromMxc(uri).getSquareThumbnailHttp(96);
@ -123,7 +124,7 @@ export default class ProfileSettings extends React.Component<{}, IState> {
logger.log("Failed to save profile", err);
Modal.createDialog(ErrorDialog, {
title: _t("Failed to save your profile"),
description: ((err && err.message) ? err.message : _t("The operation could not be completed")),
description: err && err.message ? err.message : _t("The operation could not be completed"),
});
}
@ -160,32 +161,32 @@ export default class ProfileSettings extends React.Component<{}, IState> {
};
public render(): JSX.Element {
const hostingSignupLink = getHostingLink('user-settings');
const hostingSignupLink = getHostingLink("user-settings");
let hostingSignup = null;
if (hostingSignupLink) {
hostingSignup = <span>
{ _t(
"<a>Upgrade</a> to your own domain", {},
{
a: sub => <ExternalLink href={hostingSignupLink} target="_blank" rel="noreferrer noopener">
{ sub }
</ExternalLink>,
},
) }
</span>;
hostingSignup = (
<span>
{_t(
"<a>Upgrade</a> to your own domain",
{},
{
a: (sub) => (
<ExternalLink href={hostingSignupLink} target="_blank" rel="noreferrer noopener">
{sub}
</ExternalLink>
),
},
)}
</span>
);
}
const userIdentifier = UserIdentifierCustomisations.getDisplayUserIdentifier(
this.state.userId, { withDisplayName: true },
);
const userIdentifier = UserIdentifierCustomisations.getDisplayUserIdentifier(this.state.userId, {
withDisplayName: true,
});
return (
<form
onSubmit={this.saveProfile}
autoComplete="off"
noValidate={true}
className="mx_ProfileSettings"
>
<form onSubmit={this.saveProfile} autoComplete="off" noValidate={true} className="mx_ProfileSettings">
<input
type="file"
ref={this.avatarUpload}
@ -199,7 +200,7 @@ export default class ProfileSettings extends React.Component<{}, IState> {
/>
<div className="mx_ProfileSettings_profile">
<div className="mx_ProfileSettings_profile_controls">
<span className="mx_SettingsTab_subheading">{ _t("Profile") }</span>
<span className="mx_SettingsTab_subheading">{_t("Profile")}</span>
<Field
label={_t("Display Name")}
type="text"
@ -208,10 +209,10 @@ export default class ProfileSettings extends React.Component<{}, IState> {
onChange={this.onDisplayNameChanged}
/>
<p>
{ userIdentifier && <span className="mx_ProfileSettings_profile_controls_userId">
{ userIdentifier }
</span> }
{ hostingSignup }
{userIdentifier && (
<span className="mx_ProfileSettings_profile_controls_userId">{userIdentifier}</span>
)}
{hostingSignup}
</p>
</div>
<AvatarSetting
@ -219,7 +220,8 @@ export default class ProfileSettings extends React.Component<{}, IState> {
avatarName={this.state.displayName || this.state.userId}
avatarAltText={_t("Profile picture")}
uploadAvatar={this.uploadAvatar}
removeAvatar={this.removeAvatar} />
removeAvatar={this.removeAvatar}
/>
</div>
<div className="mx_ProfileSettings_buttons">
<AccessibleButton
@ -227,14 +229,14 @@ export default class ProfileSettings extends React.Component<{}, IState> {
kind="link"
disabled={!this.state.enableProfileSave}
>
{ _t("Cancel") }
{_t("Cancel")}
</AccessibleButton>
<AccessibleButton
onClick={this.saveProfile}
kind="primary"
disabled={!this.state.enableProfileSave}
>
{ _t("Save") }
{_t("Save")}
</AccessibleButton>
</div>
</form>