-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove the client side filtering from the room dir #2750
Conversation
This removes the ability for the client to filter remote room directories by network, since the /thirdparty/protocols API does not yet work for remote servers. They would only get the main list now though anyway, so there is no point in us continuing to support it.
opts.third_party_instance_id = this.state.instance_id; | ||
} else if (this.state.network !== '_matrix') { | ||
if (this.state.instanceId) { | ||
opts.third_party_instanceId = this.state.instanceId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not convinced third_party_instanceId
is the right format to give to synapse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
heh, good catch!
@@ -295,12 +284,19 @@ module.exports = React.createClass({ | |||
onJoinClick: function(alias) { | |||
// If we're on the 'Matrix' network (or all networks), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment needs updating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
this.showRoomAlias(alias); | ||
} else { | ||
// This is a 3rd party protocol. Let's see if we | ||
// can join it | ||
const fields = this._getFieldsForThirdPartyLocation(alias, this.state.network); | ||
const protocol_name = protocolNameForInstanceId(this.protocols, this.state.instanceId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
protocol_name
-> protocolName
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
export function protocolNameForInstanceId(protocols, instance_id) { | ||
if (!instance_id) return null; | ||
for (const proto of Object.keys(protocols)) { | ||
if (!protocols[proto].instances) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should probably be checking whether instances is an array, in case it's an object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -309,8 +305,7 @@ module.exports = React.createClass({ | |||
}); | |||
return; | |||
} | |||
const protocol = this._protocolForThirdPartyNetwork(this.state.network); | |||
MatrixClientPeg.get().getThirdpartyLocation(protocol, fields).done((resp) => { | |||
MatrixClientPeg.get().getThirdpartyLocation(protocol_name, fields).done((resp) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to null guard protocol_name
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if (matched_instance === undefined) return null; | ||
|
||
// now make an object with the fields specified by that protocol. We | ||
_getFieldsForThirdPartyLocation: function(user_input, protocol, instance) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userInput
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
// require that the values of all but the last field come from the | ||
// instance. The last is the user input. | ||
const required_fields = this.protocols[network_info.protocol].location_fields; | ||
const required_fields = protocol.location_fields; | ||
if (!required_fields) return null; | ||
const fields = {}; | ||
for (let i = 0; i < required_fields.length - 1; ++i) { | ||
const this_field = required_fields[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thisField
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
for (const proto of Object.keys(this.props.protocols)) { | ||
if (!this.props.protocols[proto].instances) continue; | ||
for (const instance of this.props.protocols[proto].instances) { | ||
if (!instance.instance_id) continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels like it could use protocolNameForInstanceId
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case we're just iterating through the protocols response to make an option for each, rather than getting one particular protocol / instance
icon = <img src={iconPath} />; | ||
} | ||
|
||
key = server + '_inst_'+instance.instance_id; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'_inst_' + instan...
protocols: {}, | ||
config: {}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe comment within config
to explain the optional servers
property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've put it in propTypes
I'm new to this scheme of variable names, could you quickly explain the use of underscores at times vs. use of other casings? |
Basically we were a bit inconsistent, which vdh pointed out in his last review, so I'd been trying to make them a bit more consistent and make parameter names camelcase at least. If there anything that looks wrong? |
Well it's just that sometimes variable names are camelcase and some are underscored. One example is handleClicks vs. includeAll |
yeah, they generally should be camelcase |
@@ -278,7 +267,7 @@ module.exports = React.createClass({ | |||
this.filterTimeout = setTimeout(() => { | |||
this.filterTimeout = null; | |||
this.refreshRoomList(); | |||
}, 300); | |||
}, 700); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the bump?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
700ms still feels pretty responsive, and will help further reduce the number of hits to the API
// If we're on the 'Matrix' network (or all networks), | ||
// just show that rooms alias | ||
if (this.state.network == null || this.state.network == '_matrix') { | ||
// If we don't have a prticular instance id selected, just show that rooms alias |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prticular
Probably LGTM - It's hard to adequately review this without knowing the context of what it was like before, and given the expedited need for this PR to land, assuming it works, LGTM. |
Yay! |
This removes the ability for the client to filter remote room
directories by network, since the /thirdparty/protocols API does
not yet work for remote servers. They would only get the main list
now though anyway, so there is no point in us continuing to support
it.