From bffce8689a435eb876fe0f7accfa97a6a664ea81 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 5 Feb 2021 13:34:06 +0000 Subject: [PATCH 1/3] Allow saving room topic or name only This changes the room profile settings to support saving _only_ the room topic or name in case you have limited access to set one but not the other. Fixes https://github.com/vector-im/element-web/issues/16375 --- src/components/views/room_settings/RoomProfileSettings.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/views/room_settings/RoomProfileSettings.js b/src/components/views/room_settings/RoomProfileSettings.js index c76c0823e4..e90dab3b97 100644 --- a/src/components/views/room_settings/RoomProfileSettings.js +++ b/src/components/views/room_settings/RoomProfileSettings.js @@ -81,7 +81,11 @@ export default class RoomProfileSettings extends React.Component { if (!this.state.enableProfileSave) return; this._removeAvatar(); - this.setState({enableProfileSave: false, displayName: this.state.originalDisplayName}); + this.setState({ + enableProfileSave: false, + displayName: this.state.originalDisplayName, + topic: this.state.originalTopic, + }); }; _saveProfile = async (e) => { @@ -164,7 +168,7 @@ export default class RoomProfileSettings extends React.Component { const AvatarSetting = sdk.getComponent('settings.AvatarSetting'); let profileSettingsButtons; - if (this.state.canSetTopic && this.state.canSetName) { + if (this.state.canSetTopic || this.state.canSetName) { profileSettingsButtons = (
Date: Fri, 5 Feb 2021 13:47:20 +0000 Subject: [PATCH 2/3] Normalise cancel behaviour for room avatar This normalises the behaviour of the "Cancel" button for the room profile so that it _always_ restores the existing value for all of room name, topic, and avatar, instead of performing a mix of restore and remove. Fixes https://github.com/vector-im/element-web/issues/16375 --- .../room_settings/RoomProfileSettings.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/components/views/room_settings/RoomProfileSettings.js b/src/components/views/room_settings/RoomProfileSettings.js index e90dab3b97..c651216e8c 100644 --- a/src/components/views/room_settings/RoomProfileSettings.js +++ b/src/components/views/room_settings/RoomProfileSettings.js @@ -69,22 +69,23 @@ export default class RoomProfileSettings extends React.Component { // clear file upload field so same file can be selected this._avatarUpload.current.value = ""; this.setState({ - avatarUrl: undefined, - avatarFile: undefined, + avatarUrl: null, + avatarFile: null, enableProfileSave: true, }); }; - _clearProfile = async (e) => { + _cancelProfileChanges = async (e) => { e.stopPropagation(); e.preventDefault(); if (!this.state.enableProfileSave) return; - this._removeAvatar(); this.setState({ enableProfileSave: false, displayName: this.state.originalDisplayName, topic: this.state.originalTopic, + avatarUrl: this.state.originalAvatarUrl, + avatarFile: null, }); }; @@ -112,7 +113,7 @@ export default class RoomProfileSettings extends React.Component { newState.originalAvatarUrl = newState.avatarUrl; newState.avatarFile = null; } 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) { @@ -168,11 +169,15 @@ export default class RoomProfileSettings extends React.Component { const AvatarSetting = sdk.getComponent('settings.AvatarSetting'); let profileSettingsButtons; - if (this.state.canSetTopic || this.state.canSetName) { + if ( + this.state.canSetName || + this.state.canSetTopic || + this.state.canSetAvatar + ) { profileSettingsButtons = (
From 81bd919a185e0c1ec7cb4e7845a405b349b81abd Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 5 Feb 2021 14:11:57 +0000 Subject: [PATCH 3/3] Port avatar restore to user profile settings --- src/components/views/settings/ProfileSettings.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/views/settings/ProfileSettings.js b/src/components/views/settings/ProfileSettings.js index c11a2e3a5e..4dc69884c3 100644 --- a/src/components/views/settings/ProfileSettings.js +++ b/src/components/views/settings/ProfileSettings.js @@ -52,19 +52,23 @@ export default class ProfileSettings extends React.Component { // clear file upload field so same file can be selected this._avatarUpload.current.value = ""; this.setState({ - avatarUrl: undefined, - avatarFile: undefined, + avatarUrl: null, + avatarFile: null, enableProfileSave: true, }); }; - _clearProfile = async (e) => { + _cancelProfileChanges = async (e) => { e.stopPropagation(); e.preventDefault(); if (!this.state.enableProfileSave) return; - this._removeAvatar(); - this.setState({enableProfileSave: false, displayName: this.state.originalDisplayName}); + this.setState({ + enableProfileSave: false, + displayName: this.state.originalDisplayName, + avatarUrl: this.state.originalAvatarUrl, + avatarFile: null, + }); }; _saveProfile = async (e) => { @@ -186,7 +190,7 @@ export default class ProfileSettings extends React.Component {