diff --git a/src/components/structures/RoomDirectory.js b/src/components/structures/RoomDirectory.js
index b155f514f4..d0c0c32eaa 100644
--- a/src/components/structures/RoomDirectory.js
+++ b/src/components/structures/RoomDirectory.js
@@ -515,20 +515,9 @@ module.exports = React.createClass({
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
const AccessibleButton = sdk.getComponent('elements.AccessibleButton');
- // TODO: clean this up
- if (this.state.protocolsLoading) {
- return (
-
-
-
- );
- }
-
let content;
- if (this.state.loading) {
- content =
-
-
;
+ if (this.state.protocolsLoading || this.state.loading) {
+ content = ;
} else {
const rows = this.getRows();
// we still show the scrollpanel, at least for now, because
@@ -556,33 +545,48 @@ module.exports = React.createClass({
;
}
- const protocolName = protocolNameForInstanceId(this.protocols, this.state.instanceId);
- let instance_expected_field_type;
- if (
- protocolName &&
- this.protocols &&
- this.protocols[protocolName] &&
- this.protocols[protocolName].location_fields.length > 0 &&
- this.protocols[protocolName].field_types
- ) {
- const last_field = this.protocols[protocolName].location_fields.slice(-1)[0];
- instance_expected_field_type = this.protocols[protocolName].field_types[last_field];
- }
+ let listHeader;
+ if (!this.state.protocolsLoading) {
+ const NetworkDropdown = sdk.getComponent('directory.NetworkDropdown');
+ const DirectorySearchBox = sdk.getComponent('elements.DirectorySearchBox');
-
- let placeholder = _t('Search for a room');
- if (!this.state.instanceId) {
- placeholder = _t('Search for a room like #example') + ':' + this.state.roomServer;
- } else if (instance_expected_field_type) {
- placeholder = instance_expected_field_type.placeholder;
- }
-
- let showJoinButton = this._stringLooksLikeId(this.state.filterString, instance_expected_field_type);
- if (protocolName) {
- const instance = instanceForInstanceId(this.protocols, this.state.instanceId);
- if (this._getFieldsForThirdPartyLocation(this.state.filterString, this.protocols[protocolName], instance) === null) {
- showJoinButton = false;
+ const protocolName = protocolNameForInstanceId(this.protocols, this.state.instanceId);
+ let instance_expected_field_type;
+ if (
+ protocolName &&
+ this.protocols &&
+ this.protocols[protocolName] &&
+ this.protocols[protocolName].location_fields.length > 0 &&
+ this.protocols[protocolName].field_types
+ ) {
+ const last_field = this.protocols[protocolName].location_fields.slice(-1)[0];
+ instance_expected_field_type = this.protocols[protocolName].field_types[last_field];
}
+
+
+ let placeholder = _t('Search for a room');
+ if (!this.state.instanceId) {
+ placeholder = _t('Search for a room like #example') + ':' + this.state.roomServer;
+ } else if (instance_expected_field_type) {
+ placeholder = instance_expected_field_type.placeholder;
+ }
+
+ let showJoinButton = this._stringLooksLikeId(this.state.filterString, instance_expected_field_type);
+ if (protocolName) {
+ const instance = instanceForInstanceId(this.protocols, this.state.instanceId);
+ if (this._getFieldsForThirdPartyLocation(this.state.filterString, this.protocols[protocolName], instance) === null) {
+ showJoinButton = false;
+ }
+ }
+
+ listHeader =
+
+
+
;
}
const createRoomButton = ({_t("Create new room")});
- const NetworkDropdown = sdk.getComponent('directory.NetworkDropdown');
- const DirectorySearchBox = sdk.getComponent('elements.DirectorySearchBox');
return (
-
-
-
-
+ {listHeader}
{content}