Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -14,7 +14,7 @@ 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 classNames from "classnames";
|
||||
|
||||
import { _t } from "../../../languageHandler";
|
||||
|
@ -23,7 +23,7 @@ import Field from "../elements/Field";
|
|||
import { mediaFromMxc } from "../../../customisations/Media";
|
||||
import AccessibleButton from "../elements/AccessibleButton";
|
||||
import AvatarSetting from "../settings/AvatarSetting";
|
||||
import { htmlSerializeFromMdIfNeeded } from '../../../editor/serialize';
|
||||
import { htmlSerializeFromMdIfNeeded } from "../../../editor/serialize";
|
||||
import { chromeFileInputFix } from "../../../utils/BrowserWorkarounds";
|
||||
|
||||
interface IProps {
|
||||
|
@ -60,10 +60,10 @@ export default class RoomProfileSettings extends React.Component<IProps, IState>
|
|||
if (avatarUrl) avatarUrl = mediaFromMxc(avatarUrl).getSquareThumbnailHttp(96);
|
||||
|
||||
const topicEvent = room.currentState.getStateEvents("m.room.topic", "");
|
||||
const topic = topicEvent && topicEvent.getContent() ? topicEvent.getContent()['topic'] : '';
|
||||
const topic = topicEvent && topicEvent.getContent() ? topicEvent.getContent()["topic"] : "";
|
||||
|
||||
const nameEvent = room.currentState.getStateEvents('m.room.name', '');
|
||||
const name = nameEvent && nameEvent.getContent() ? nameEvent.getContent()['name'] : '';
|
||||
const nameEvent = room.currentState.getStateEvents("m.room.name", "");
|
||||
const name = nameEvent && nameEvent.getContent() ? nameEvent.getContent()["name"] : "";
|
||||
|
||||
this.state = {
|
||||
originalDisplayName: name,
|
||||
|
@ -74,9 +74,9 @@ export default class RoomProfileSettings extends React.Component<IProps, IState>
|
|||
originalTopic: topic,
|
||||
topic: topic,
|
||||
profileFieldsTouched: {},
|
||||
canSetName: room.currentState.maySendStateEvent('m.room.name', client.getUserId()),
|
||||
canSetTopic: room.currentState.maySendStateEvent('m.room.topic', client.getUserId()),
|
||||
canSetAvatar: room.currentState.maySendStateEvent('m.room.avatar', client.getUserId()),
|
||||
canSetName: room.currentState.maySendStateEvent("m.room.name", client.getUserId()),
|
||||
canSetTopic: room.currentState.maySendStateEvent("m.room.topic", client.getUserId()),
|
||||
canSetAvatar: room.currentState.maySendStateEvent("m.room.avatar", client.getUserId()),
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -135,12 +135,12 @@ export default class RoomProfileSettings extends React.Component<IProps, IState>
|
|||
|
||||
if (this.state.avatarFile) {
|
||||
const { content_uri: uri } = await client.uploadContent(this.state.avatarFile);
|
||||
await client.sendStateEvent(this.props.roomId, 'm.room.avatar', { url: uri }, '');
|
||||
await client.sendStateEvent(this.props.roomId, "m.room.avatar", { url: uri }, "");
|
||||
newState.avatarUrl = mediaFromMxc(uri).getSquareThumbnailHttp(96);
|
||||
newState.originalAvatarUrl = newState.avatarUrl;
|
||||
newState.avatarFile = null;
|
||||
} else if (this.state.originalAvatarUrl !== this.state.avatarUrl) {
|
||||
await client.sendStateEvent(this.props.roomId, 'm.room.avatar', {}, '');
|
||||
await client.sendStateEvent(this.props.roomId, "m.room.avatar", {}, "");
|
||||
}
|
||||
|
||||
if (this.state.originalTopic !== this.state.topic) {
|
||||
|
@ -220,38 +220,21 @@ export default class RoomProfileSettings extends React.Component<IProps, IState>
|
|||
|
||||
public render(): JSX.Element {
|
||||
let profileSettingsButtons;
|
||||
if (
|
||||
this.state.canSetName ||
|
||||
this.state.canSetTopic ||
|
||||
this.state.canSetAvatar
|
||||
) {
|
||||
if (this.state.canSetName || this.state.canSetTopic || this.state.canSetAvatar) {
|
||||
profileSettingsButtons = (
|
||||
<div className="mx_ProfileSettings_buttons">
|
||||
<AccessibleButton
|
||||
onClick={this.cancelProfileChanges}
|
||||
kind="link"
|
||||
disabled={!this.isSaveEnabled()}
|
||||
>
|
||||
{ _t("Cancel") }
|
||||
<AccessibleButton onClick={this.cancelProfileChanges} kind="link" disabled={!this.isSaveEnabled()}>
|
||||
{_t("Cancel")}
|
||||
</AccessibleButton>
|
||||
<AccessibleButton
|
||||
onClick={this.saveProfile}
|
||||
kind="primary"
|
||||
disabled={!this.isSaveEnabled()}
|
||||
>
|
||||
{ _t("Save") }
|
||||
<AccessibleButton onClick={this.saveProfile} kind="primary" disabled={!this.isSaveEnabled()}>
|
||||
{_t("Save")}
|
||||
</AccessibleButton>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
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}
|
||||
|
@ -290,9 +273,10 @@ export default class RoomProfileSettings extends React.Component<IProps, IState>
|
|||
avatarName={this.state.displayName || this.props.roomId}
|
||||
avatarAltText={_t("Room avatar")}
|
||||
uploadAvatar={this.state.canSetAvatar ? this.uploadAvatar : undefined}
|
||||
removeAvatar={this.state.canSetAvatar ? this.removeAvatar : undefined} />
|
||||
removeAvatar={this.state.canSetAvatar ? this.removeAvatar : undefined}
|
||||
/>
|
||||
</div>
|
||||
{ profileSettingsButtons }
|
||||
{profileSettingsButtons}
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue