PR Freedback

This commit is contained in:
David Baker 2016-10-04 11:04:01 +01:00
parent 000ca35727
commit 304e5b997a
2 changed files with 20 additions and 19 deletions

View file

@ -132,7 +132,7 @@ module.exports = React.createClass({
opts.server = my_server; opts.server = my_server;
} }
if (this.nextBatch) opts.since = this.nextBatch; if (this.nextBatch) opts.since = this.nextBatch;
if (this.state.filterString) opts.filter = { generic_search_term: my_filter_string } ; if (my_filter_string) opts.filter = { generic_search_term: my_filter_string } ;
return MatrixClientPeg.get().publicRooms(opts).then((data) => { return MatrixClientPeg.get().publicRooms(opts).then((data) => {
if ( if (
my_filter_string != this.state.filterString || my_filter_string != this.state.filterString ||
@ -498,7 +498,7 @@ module.exports = React.createClass({
if (!this.protocols) return null; if (!this.protocols) return null;
let instance; let matched_instance;
// Try to find which instance in the 'protocols' response // Try to find which instance in the 'protocols' response
// matches this network. We look for a matching protocol // matches this network. We look for a matching protocol
// and the existence of a 'domain' field and if present, // and the existence of a 'domain' field and if present,
@ -509,18 +509,18 @@ module.exports = React.createClass({
// as long as it has no domain (which we assume to mean it's // as long as it has no domain (which we assume to mean it's
// there is only one possible instance). // there is only one possible instance).
if (the_instance.fields.domain === undefined && network_info.domain === undefined) { if (the_instance.fields.domain === undefined && network_info.domain === undefined) {
instance = this.protocols[network_info.protocol].instances[0]; matched_instance = this.protocols[network_info.protocol].instances[0];
} }
} else if (network_info.domain) { } else if (network_info.domain) {
// otherwise, we look for one with a matching domain. // otherwise, we look for one with a matching domain.
for (const this_instance of this.protocols[network_info.protocol].instances) { for (const this_instance of this.protocols[network_info.protocol].instances) {
if (this_instance.fields.domain == network_info.domain) { if (this_instance.fields.domain == network_info.domain) {
instance = this_instance; matched_instance = this_instance;
} }
} }
} }
if (instance === undefined) return null; if (matched_instance === undefined) return null;
// now make an object with the fields specified by that protocol. We // now make an object with the fields specified by that protocol. We
// require that the values of all but the last field come from the // require that the values of all but the last field come from the
@ -529,8 +529,8 @@ module.exports = React.createClass({
const fields = {}; const fields = {};
for (let i = 0; i < required_fields.length - 1; ++i) { for (let i = 0; i < required_fields.length - 1; ++i) {
const this_field = required_fields[i]; const this_field = required_fields[i];
if (instance.fields[this_field] === undefined) return null; if (matched_instance.fields[this_field] === undefined) return null;
fields[this_field] = instance.fields[this_field]; fields[this_field] = matched_instance.fields[this_field];
} }
fields[required_fields[required_fields.length - 1]] = user_input; fields[required_fields[required_fields.length - 1]] = user_input;
return fields; return fields;

View file

@ -170,17 +170,18 @@ export default class NetworkDropdown extends React.Component {
icon = <img src="img/network-matrix.svg" width="16" height="16" />; icon = <img src="img/network-matrix.svg" width="16" height="16" />;
span_class = 'mx_NetworkDropdown_menu_network'; span_class = 'mx_NetworkDropdown_menu_network';
} else { } else {
if (this.props.config.networks[network]) { if (this.props.config.networks[network] === undefined) {
if (this.props.config.networks[network].name) { throw new Error(network + ' network missing from config');
name = this.props.config.networks[network].name; }
} else { if (this.props.config.networks[network].name) {
name = network; name = this.props.config.networks[network].name;
} } else {
if (this.props.config.networks[network].icon) { name = network;
icon = <img src={this.props.config.networks[network].icon} />; }
} else { if (this.props.config.networks[network].icon) {
icon = <img src={iconPath} width="16" height="16" />; icon = <img src={this.props.config.networks[network].icon} />;
} } else {
icon = <img src={iconPath} width="16" height="16" />;
} }
span_class = 'mx_NetworkDropdown_menu_network'; span_class = 'mx_NetworkDropdown_menu_network';
@ -210,7 +211,7 @@ export default class NetworkDropdown extends React.Component {
</div>; </div>;
current_value = <input type="text" className="mx_NetworkDropdown_networkoption" current_value = <input type="text" className="mx_NetworkDropdown_networkoption"
ref={this.collectInputTextBox} onKeyUp={this.onInputKeyUp} ref={this.collectInputTextBox} onKeyUp={this.onInputKeyUp}
placeholder="matrix.org" placeholder="matrix.org" // 'matrix.org' as an example of an HS name
/> />
} else { } else {
current_value = this._makeMenuOption( current_value = this._makeMenuOption(