Merge pull request #5620 from matrix-org/jryans/room-topic-only
Fix several profile settings oddities
This commit is contained in:
commit
32310abc14
2 changed files with 27 additions and 14 deletions
|
@ -69,19 +69,24 @@ export default class RoomProfileSettings extends React.Component {
|
||||||
// clear file upload field so same file can be selected
|
// clear file upload field so same file can be selected
|
||||||
this._avatarUpload.current.value = "";
|
this._avatarUpload.current.value = "";
|
||||||
this.setState({
|
this.setState({
|
||||||
avatarUrl: undefined,
|
avatarUrl: null,
|
||||||
avatarFile: undefined,
|
avatarFile: null,
|
||||||
enableProfileSave: true,
|
enableProfileSave: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_clearProfile = async (e) => {
|
_cancelProfileChanges = async (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!this.state.enableProfileSave) return;
|
if (!this.state.enableProfileSave) return;
|
||||||
this._removeAvatar();
|
this.setState({
|
||||||
this.setState({enableProfileSave: false, displayName: this.state.originalDisplayName});
|
enableProfileSave: false,
|
||||||
|
displayName: this.state.originalDisplayName,
|
||||||
|
topic: this.state.originalTopic,
|
||||||
|
avatarUrl: this.state.originalAvatarUrl,
|
||||||
|
avatarFile: null,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_saveProfile = async (e) => {
|
_saveProfile = async (e) => {
|
||||||
|
@ -108,7 +113,7 @@ export default class RoomProfileSettings extends React.Component {
|
||||||
newState.originalAvatarUrl = newState.avatarUrl;
|
newState.originalAvatarUrl = newState.avatarUrl;
|
||||||
newState.avatarFile = null;
|
newState.avatarFile = null;
|
||||||
} else if (this.state.originalAvatarUrl !== this.state.avatarUrl) {
|
} else if (this.state.originalAvatarUrl !== this.state.avatarUrl) {
|
||||||
await client.sendStateEvent(this.props.roomId, 'm.room.avatar', {url: undefined}, '');
|
await client.sendStateEvent(this.props.roomId, 'm.room.avatar', {}, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.state.originalTopic !== this.state.topic) {
|
if (this.state.originalTopic !== this.state.topic) {
|
||||||
|
@ -164,11 +169,15 @@ export default class RoomProfileSettings extends React.Component {
|
||||||
const AvatarSetting = sdk.getComponent('settings.AvatarSetting');
|
const AvatarSetting = sdk.getComponent('settings.AvatarSetting');
|
||||||
|
|
||||||
let profileSettingsButtons;
|
let profileSettingsButtons;
|
||||||
if (this.state.canSetTopic && this.state.canSetName) {
|
if (
|
||||||
|
this.state.canSetName ||
|
||||||
|
this.state.canSetTopic ||
|
||||||
|
this.state.canSetAvatar
|
||||||
|
) {
|
||||||
profileSettingsButtons = (
|
profileSettingsButtons = (
|
||||||
<div className="mx_ProfileSettings_buttons">
|
<div className="mx_ProfileSettings_buttons">
|
||||||
<AccessibleButton
|
<AccessibleButton
|
||||||
onClick={this._clearProfile}
|
onClick={this._cancelProfileChanges}
|
||||||
kind="link"
|
kind="link"
|
||||||
disabled={!this.state.enableProfileSave}
|
disabled={!this.state.enableProfileSave}
|
||||||
>
|
>
|
||||||
|
|
|
@ -52,19 +52,23 @@ export default class ProfileSettings extends React.Component {
|
||||||
// clear file upload field so same file can be selected
|
// clear file upload field so same file can be selected
|
||||||
this._avatarUpload.current.value = "";
|
this._avatarUpload.current.value = "";
|
||||||
this.setState({
|
this.setState({
|
||||||
avatarUrl: undefined,
|
avatarUrl: null,
|
||||||
avatarFile: undefined,
|
avatarFile: null,
|
||||||
enableProfileSave: true,
|
enableProfileSave: true,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_clearProfile = async (e) => {
|
_cancelProfileChanges = async (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!this.state.enableProfileSave) return;
|
if (!this.state.enableProfileSave) return;
|
||||||
this._removeAvatar();
|
this.setState({
|
||||||
this.setState({enableProfileSave: false, displayName: this.state.originalDisplayName});
|
enableProfileSave: false,
|
||||||
|
displayName: this.state.originalDisplayName,
|
||||||
|
avatarUrl: this.state.originalAvatarUrl,
|
||||||
|
avatarFile: null,
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
_saveProfile = async (e) => {
|
_saveProfile = async (e) => {
|
||||||
|
@ -186,7 +190,7 @@ export default class ProfileSettings extends React.Component {
|
||||||
</div>
|
</div>
|
||||||
<div className="mx_ProfileSettings_buttons">
|
<div className="mx_ProfileSettings_buttons">
|
||||||
<AccessibleButton
|
<AccessibleButton
|
||||||
onClick={this._clearProfile}
|
onClick={this._cancelProfileChanges}
|
||||||
kind="link"
|
kind="link"
|
||||||
disabled={!this.state.enableProfileSave}
|
disabled={!this.state.enableProfileSave}
|
||||||
>
|
>
|
||||||
|
|
Loading…
Reference in a new issue