Skip to content
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

Merged
merged 4 commits into from
Dec 16, 2016

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Dec 16, 2016

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.

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;
Copy link
Contributor

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.

Copy link
Member Author

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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment needs updating

Copy link
Member Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protocol_name -> protocolName

Copy link
Member Author

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;
Copy link
Contributor

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.

Copy link
Member Author

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) => {
Copy link
Contributor

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.

Copy link
Member Author

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userInput

Copy link
Member Author

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];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thisField

Copy link
Member Author

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;
Copy link
Contributor

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

Copy link
Member Author

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'_inst_' + instan...

protocols: {},
config: {},
Copy link
Contributor

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

Copy link
Member Author

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

@lukebarnard1
Copy link
Contributor

I'm new to this scheme of variable names, could you quickly explain the use of underscores at times vs. use of other casings?

@dbkr
Copy link
Member Author

dbkr commented Dec 16, 2016

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?

@lukebarnard1
Copy link
Contributor

Well it's just that sometimes variable names are camelcase and some are underscored. One example is handleClicks vs. includeAll

@dbkr
Copy link
Member Author

dbkr commented Dec 16, 2016

yeah, they generally should be camelcase

@@ -278,7 +267,7 @@ module.exports = React.createClass({
this.filterTimeout = setTimeout(() => {
this.filterTimeout = null;
this.refreshRoomList();
}, 300);
}, 700);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the bump?

Copy link
Member Author

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

prticular

@kegsay
Copy link
Contributor

kegsay commented Dec 16, 2016

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.

@dbkr
Copy link
Member Author

dbkr commented Dec 16, 2016

Yay!

@dbkr dbkr merged commit 09f79b9 into develop Dec 16, 2016
@t3chguy t3chguy deleted the dbkr/roomdir_remove_client_filter branch May 12, 2022 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants