Fix Room Directory custom homeserver entry not showing propely

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2019-02-26 23:25:31 +00:00
parent 150c941340
commit fbe4d52b48

View file

@ -41,8 +41,8 @@ export default class NetworkDropdown extends React.Component {
this.state = { this.state = {
expanded: false, expanded: false,
selectedServer: server, selectedServer: server,
selectedInstance: null, selectedInstanceId: null,
includeAllNetworks: false, includeAllNetworks: true,
}; };
} }
@ -52,7 +52,8 @@ export default class NetworkDropdown extends React.Component {
document.addEventListener('click', this.onDocumentClick, false); document.addEventListener('click', this.onDocumentClick, false);
// fire this now so the defaults can be set up // fire this now so the defaults can be set up
this.props.onOptionChange(this.state.selectedServer, this.state.selectedInstance, this.state.includeAllNetworks); const {selectedServer, selectedInstanceId, includeAllNetworks} = this.state;
this.props.onOptionChange(selectedServer, selectedInstanceId, includeAllNetworks);
} }
componentWillUnmount() { componentWillUnmount() {
@ -97,17 +98,18 @@ export default class NetworkDropdown extends React.Component {
expanded: false, expanded: false,
selectedServer: server, selectedServer: server,
selectedInstanceId: instance ? instance.instance_id : null, selectedInstanceId: instance ? instance.instance_id : null,
includeAll: includeAll, includeAllNetworks: includeAll,
}); });
this.props.onOptionChange(server, instance ? instance.instance_id : null, includeAll); this.props.onOptionChange(server, instance ? instance.instance_id : null, includeAll);
} }
onInputKeyUp(e) { onInputKeyUp(e) {
if (e.key == 'Enter') { if (e.key === 'Enter') {
this.setState({ this.setState({
expanded: false, expanded: false,
selectedServer: e.target.value, selectedServer: e.target.value,
selectedNetwork: null, selectedNetwork: null,
includeAllNetworks: true,
}); });
this.props.onOptionChange(e.target.value, null); this.props.onOptionChange(e.target.value, null);
} }
@ -227,7 +229,7 @@ export default class NetworkDropdown extends React.Component {
} else { } else {
const instance = instanceForInstanceId(this.props.protocols, this.state.selectedInstanceId); const instance = instanceForInstanceId(this.props.protocols, this.state.selectedInstanceId);
current_value = this._makeMenuOption( current_value = this._makeMenuOption(
this.state.selectedServer, instance, this.state.includeAll, false, this.state.selectedServer, instance, this.state.includeAllNetworks, false,
); );
} }