Fix click on faded left/right/middle panel -> close settings

- implement generic dispatch to close user/room/group settings
 - use dispatch to allow clicks on disabled left/right/middle panel to
   close settings

A much more maintainable approach would be to use dedicate routing
instead of doing different things depending on what page of the app is
currently being viewed. At the very least we could make the concept of a
settings page generic.
This commit is contained in:
Luke Barnard 2018-05-29 13:16:39 +01:00
parent b2c26e6984
commit da9fe9917b
5 changed files with 100 additions and 48 deletions

View file

@ -182,6 +182,7 @@ module.exports = React.createClass({
isInitialEventHighlighted: RoomViewStore.isInitialEventHighlighted(),
forwardingEvent: RoomViewStore.getForwardingEvent(),
shouldPeek: RoomViewStore.shouldPeek(),
editingRoomSettings: RoomViewStore.isEditingSettings(),
};
// Temporary logging to diagnose https://github.com/vector-im/riot-web/issues/4307
@ -1139,7 +1140,7 @@ module.exports = React.createClass({
},
onSettingsClick: function() {
this.showSettings(true);
dis.dispatch({ action: 'open_room_settings' });
},
onSettingsSaveClick: function() {
@ -1172,24 +1173,20 @@ module.exports = React.createClass({
});
// still editing room settings
} else {
this.setState({
editingRoomSettings: false,
});
dis.dispatch({ action: 'close_settings' });
}
}).finally(() => {
this.setState({
uploadingRoomSettings: false,
editingRoomSettings: false,
});
dis.dispatch({ action: 'close_settings' });
}).done();
},
onCancelClick: function() {
console.log("updateTint from onCancelClick");
this.updateTint();
this.setState({
editingRoomSettings: false,
});
dis.dispatch({ action: 'close_settings' });
if (this.state.forwardingEvent) {
dis.dispatch({
action: 'forward_event',
@ -1406,13 +1403,6 @@ module.exports = React.createClass({
});*/
},
showSettings: function(show) {
// XXX: this is a bit naughty; we should be doing this via props
if (show) {
this.setState({editingRoomSettings: true});
}
},
/**
* called by the parent component when PageUp/Down/etc is pressed.
*