Merge pull request #2708 from matrix-org/fix_room_dict
Fix Room Directory custom homeserver entry not showing properly
This commit is contained in:
commit
080c67439b
2 changed files with 19 additions and 22 deletions
|
@ -18,7 +18,6 @@ src/components/views/create_room/RoomAlias.js
|
||||||
src/components/views/dialogs/DeactivateAccountDialog.js
|
src/components/views/dialogs/DeactivateAccountDialog.js
|
||||||
src/components/views/dialogs/SetPasswordDialog.js
|
src/components/views/dialogs/SetPasswordDialog.js
|
||||||
src/components/views/dialogs/UnknownDeviceDialog.js
|
src/components/views/dialogs/UnknownDeviceDialog.js
|
||||||
src/components/views/directory/NetworkDropdown.js
|
|
||||||
src/components/views/elements/AddressSelector.js
|
src/components/views/elements/AddressSelector.js
|
||||||
src/components/views/elements/DirectorySearchBox.js
|
src/components/views/elements/DirectorySearchBox.js
|
||||||
src/components/views/elements/ImageView.js
|
src/components/views/elements/ImageView.js
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -135,7 +137,7 @@ export default class NetworkDropdown extends React.Component {
|
||||||
servers = servers.concat(this.props.config.roomDirectory.servers);
|
servers = servers.concat(this.props.config.roomDirectory.servers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (servers.indexOf(MatrixClientPeg.getHomeServerName()) == -1) {
|
if (!servers.includes(MatrixClientPeg.getHomeServerName())) {
|
||||||
servers.unshift(MatrixClientPeg.getHomeServerName());
|
servers.unshift(MatrixClientPeg.getHomeServerName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +147,7 @@ export default class NetworkDropdown extends React.Component {
|
||||||
// we can only show the default room list.
|
// we can only show the default room list.
|
||||||
for (const server of servers) {
|
for (const server of servers) {
|
||||||
options.push(this._makeMenuOption(server, null, true));
|
options.push(this._makeMenuOption(server, null, true));
|
||||||
if (server == MatrixClientPeg.getHomeServerName()) {
|
if (server === MatrixClientPeg.getHomeServerName()) {
|
||||||
options.push(this._makeMenuOption(server, null, false));
|
options.push(this._makeMenuOption(server, null, false));
|
||||||
if (this.props.protocols) {
|
if (this.props.protocols) {
|
||||||
for (const proto of Object.keys(this.props.protocols)) {
|
for (const proto of Object.keys(this.props.protocols)) {
|
||||||
|
@ -181,18 +183,15 @@ export default class NetworkDropdown extends React.Component {
|
||||||
|
|
||||||
let icon;
|
let icon;
|
||||||
let name;
|
let name;
|
||||||
let span_class;
|
|
||||||
let key;
|
let key;
|
||||||
|
|
||||||
if (!instance && includeAll) {
|
if (!instance && includeAll) {
|
||||||
key = server;
|
key = server;
|
||||||
name = server;
|
name = server;
|
||||||
span_class = 'mx_NetworkDropdown_menu_all';
|
|
||||||
} else if (!instance) {
|
} else if (!instance) {
|
||||||
key = server + '_all';
|
key = server + '_all';
|
||||||
name = 'Matrix';
|
name = 'Matrix';
|
||||||
icon = <img src={require("../../../../res/img/network-matrix.svg")} />;
|
icon = <img src={require("../../../../res/img/network-matrix.svg")} />;
|
||||||
span_class = 'mx_NetworkDropdown_menu_network';
|
|
||||||
} else {
|
} else {
|
||||||
key = server + '_inst_' + instance.instance_id;
|
key = server + '_inst_' + instance.instance_id;
|
||||||
const imgUrl = instance.icon ?
|
const imgUrl = instance.icon ?
|
||||||
|
@ -200,41 +199,40 @@ export default class NetworkDropdown extends React.Component {
|
||||||
DEFAULT_ICON_URL;
|
DEFAULT_ICON_URL;
|
||||||
icon = <img src={imgUrl} />;
|
icon = <img src={imgUrl} />;
|
||||||
name = instance.desc;
|
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 <div key={key} className="mx_NetworkDropdown_networkoption" onClick={click_handler}>
|
return <div key={key} className="mx_NetworkDropdown_networkoption" onClick={clickHandler}>
|
||||||
{icon}
|
{icon}
|
||||||
<span className="mx_NetworkDropdown_menu_network">{name}</span>
|
<span className="mx_NetworkDropdown_menu_network">{name}</span>
|
||||||
</div>;
|
</div>;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
let current_value;
|
let currentValue;
|
||||||
|
|
||||||
let menu;
|
let menu;
|
||||||
if (this.state.expanded) {
|
if (this.state.expanded) {
|
||||||
const menu_options = this._getMenuOptions();
|
const menuOptions = this._getMenuOptions();
|
||||||
menu = <div className="mx_NetworkDropdown_menu">
|
menu = <div className="mx_NetworkDropdown_menu">
|
||||||
{menu_options}
|
{menuOptions}
|
||||||
</div>;
|
</div>;
|
||||||
current_value = <input type="text" className="mx_NetworkDropdown_networkoption"
|
currentValue = <input type="text" className="mx_NetworkDropdown_networkoption"
|
||||||
ref={this.collectInputTextBox} onKeyUp={this.onInputKeyUp}
|
ref={this.collectInputTextBox} onKeyUp={this.onInputKeyUp}
|
||||||
placeholder="matrix.org" // 'matrix.org' as an example of an HS name
|
placeholder="matrix.org" // 'matrix.org' as an example of an HS name
|
||||||
/>;
|
/>;
|
||||||
} else {
|
} else {
|
||||||
const instance = instanceForInstanceId(this.props.protocols, this.state.selectedInstanceId);
|
const instance = instanceForInstanceId(this.props.protocols, this.state.selectedInstanceId);
|
||||||
current_value = this._makeMenuOption(
|
currentValue = this._makeMenuOption(
|
||||||
this.state.selectedServer, instance, this.state.includeAll, false,
|
this.state.selectedServer, instance, this.state.includeAllNetworks, false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
return <div className="mx_NetworkDropdown" ref={this.collectRoot}>
|
return <div className="mx_NetworkDropdown" ref={this.collectRoot}>
|
||||||
<div className="mx_NetworkDropdown_input mx_no_textinput" onClick={this.onInputClick}>
|
<div className="mx_NetworkDropdown_input mx_no_textinput" onClick={this.onInputClick}>
|
||||||
{current_value}
|
{currentValue}
|
||||||
<span className="mx_NetworkDropdown_arrow"></span>
|
<span className="mx_NetworkDropdown_arrow" />
|
||||||
{menu}
|
{menu}
|
||||||
</div>
|
</div>
|
||||||
</div>;
|
</div>;
|
||||||
|
|
Loading…
Reference in a new issue