mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 21:24:59 +08:00
Handle default named rooms when editing room names
This commit is contained in:
parent
89f6459915
commit
16846c36fd
@ -28,7 +28,7 @@ module.exports = React.createClass({
|
||||
mixins: [RoomHeaderController],
|
||||
|
||||
onNameChange: function(new_name) {
|
||||
if (this.props.room.name != new_name) {
|
||||
if (this.props.room.name != new_name && new_name) {
|
||||
MatrixClientPeg.get().setRoomName(this.props.room.roomId, new_name);
|
||||
}
|
||||
},
|
||||
@ -69,8 +69,10 @@ module.exports = React.createClass({
|
||||
var topic_el = null;
|
||||
var save_button = null;
|
||||
var settings_button = null;
|
||||
var actual_name = this.props.room.currentState.getStateEvents('m.room.name', '');
|
||||
if (actual_name) actual_name = actual_name.getContent().name;
|
||||
if (this.props.editing) {
|
||||
name = <input type="text" defaultValue={this.props.room.name} ref="name_edit"/>;
|
||||
name = <input type="text" defaultValue={actual_name} placeHolder="Name" ref="name_edit"/>;
|
||||
// if (topic) topic_el = <div className="mx_RoomHeader_topic"><textarea>{ topic.getContent().topic }</textarea></div>
|
||||
save_button = (
|
||||
<div className="mx_RoomHeader_button"onClick={this.props.onSaveClick}>
|
||||
@ -78,7 +80,7 @@ module.exports = React.createClass({
|
||||
</div>
|
||||
);
|
||||
} else {
|
||||
name = <EditableText initialValue={this.props.room.name} onValueChanged={this.onNameChange} />;
|
||||
name = <EditableText label={this.props.room.name} initialValue={actual_name} placeHolder="Name" onValueChanged={this.onNameChange} />;
|
||||
if (topic) topic_el = <div className="mx_RoomHeader_topic">{ topic.getContent().topic }</div>;
|
||||
settings_button = (
|
||||
<div className="mx_RoomHeader_button" onClick={this.props.onSettingsClick}>
|
||||
|
@ -83,7 +83,7 @@ module.exports = React.createClass({
|
||||
|
||||
var deferreds = [];
|
||||
|
||||
if (old_name != new_name && new_name != undefined) {
|
||||
if (old_name != new_name && new_name != undefined && new_name) {
|
||||
deferreds.push(
|
||||
MatrixClientPeg.get().setRoomName(this.state.room.roomId, new_name)
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user