From fbe4d52b48871ca4a3e8f2ef529e5a9fb2fb60aa Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 26 Feb 2019 23:25:31 +0000 Subject: [PATCH 1/2] Fix Room Directory custom homeserver entry not showing propely Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/directory/NetworkDropdown.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/views/directory/NetworkDropdown.js b/src/components/views/directory/NetworkDropdown.js index c70cdeb0de..b2999e31cb 100644 --- a/src/components/views/directory/NetworkDropdown.js +++ b/src/components/views/directory/NetworkDropdown.js @@ -41,8 +41,8 @@ export default class NetworkDropdown extends React.Component { this.state = { expanded: false, selectedServer: server, - selectedInstance: null, - includeAllNetworks: false, + selectedInstanceId: null, + includeAllNetworks: true, }; } @@ -52,7 +52,8 @@ export default class NetworkDropdown extends React.Component { document.addEventListener('click', this.onDocumentClick, false); // 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() { @@ -97,17 +98,18 @@ export default class NetworkDropdown extends React.Component { expanded: false, selectedServer: server, selectedInstanceId: instance ? instance.instance_id : null, - includeAll: includeAll, + includeAllNetworks: includeAll, }); this.props.onOptionChange(server, instance ? instance.instance_id : null, includeAll); } onInputKeyUp(e) { - if (e.key == 'Enter') { + if (e.key === 'Enter') { this.setState({ expanded: false, selectedServer: e.target.value, selectedNetwork: null, + includeAllNetworks: true, }); this.props.onOptionChange(e.target.value, null); } @@ -227,7 +229,7 @@ export default class NetworkDropdown extends React.Component { } else { const instance = instanceForInstanceId(this.props.protocols, this.state.selectedInstanceId); current_value = this._makeMenuOption( - this.state.selectedServer, instance, this.state.includeAll, false, + this.state.selectedServer, instance, this.state.includeAllNetworks, false, ); } From eb46e62a2e8d015c7b1ff4a95d46b6f0e0751c2a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Fri, 1 Mar 2019 09:39:39 +0000 Subject: [PATCH 2/2] delint NetworkDropdown Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .eslintignore.errorfiles | 1 - .../views/directory/NetworkDropdown.js | 26 ++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/.eslintignore.errorfiles b/.eslintignore.errorfiles index d5eeebf1f2..c7d5804d66 100644 --- a/.eslintignore.errorfiles +++ b/.eslintignore.errorfiles @@ -18,7 +18,6 @@ src/components/views/create_room/RoomAlias.js src/components/views/dialogs/DeactivateAccountDialog.js src/components/views/dialogs/SetPasswordDialog.js src/components/views/dialogs/UnknownDeviceDialog.js -src/components/views/directory/NetworkDropdown.js src/components/views/elements/AddressSelector.js src/components/views/elements/DirectorySearchBox.js src/components/views/elements/ImageView.js diff --git a/src/components/views/directory/NetworkDropdown.js b/src/components/views/directory/NetworkDropdown.js index b2999e31cb..ebfff5ae8c 100644 --- a/src/components/views/directory/NetworkDropdown.js +++ b/src/components/views/directory/NetworkDropdown.js @@ -137,7 +137,7 @@ export default class NetworkDropdown extends React.Component { servers = servers.concat(this.props.config.roomDirectory.servers); } - if (servers.indexOf(MatrixClientPeg.getHomeServerName()) == -1) { + if (!servers.includes(MatrixClientPeg.getHomeServerName())) { servers.unshift(MatrixClientPeg.getHomeServerName()); } @@ -147,7 +147,7 @@ export default class NetworkDropdown extends React.Component { // we can only show the default room list. for (const server of servers) { options.push(this._makeMenuOption(server, null, true)); - if (server == MatrixClientPeg.getHomeServerName()) { + if (server === MatrixClientPeg.getHomeServerName()) { options.push(this._makeMenuOption(server, null, false)); if (this.props.protocols) { for (const proto of Object.keys(this.props.protocols)) { @@ -183,18 +183,15 @@ export default class NetworkDropdown extends React.Component { let icon; let name; - let span_class; let key; if (!instance && includeAll) { key = server; name = server; - span_class = 'mx_NetworkDropdown_menu_all'; } else if (!instance) { key = server + '_all'; name = 'Matrix'; icon = ; - span_class = 'mx_NetworkDropdown_menu_network'; } else { key = server + '_inst_' + instance.instance_id; const imgUrl = instance.icon ? @@ -202,41 +199,40 @@ export default class NetworkDropdown extends React.Component { DEFAULT_ICON_URL; icon = ; name = instance.desc; - span_class = 'mx_NetworkDropdown_menu_network'; } - const click_handler = handleClicks ? this.onMenuOptionClick.bind(this, server, instance, includeAll) : null; + const clickHandler = handleClicks ? this.onMenuOptionClick.bind(this, server, instance, includeAll) : null; - return
+ return
{icon} {name}
; } render() { - let current_value; + let currentValue; let menu; if (this.state.expanded) { - const menu_options = this._getMenuOptions(); + const menuOptions = this._getMenuOptions(); menu =
- {menu_options} + {menuOptions}
; - current_value = ; } else { const instance = instanceForInstanceId(this.props.protocols, this.state.selectedInstanceId); - current_value = this._makeMenuOption( + currentValue = this._makeMenuOption( this.state.selectedServer, instance, this.state.includeAllNetworks, false, ); } return
- {current_value} - + {currentValue} + {menu}
;