Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

hide already chosen results from AddressPickerDialog #2000

Merged
merged 5 commits into from
Jun 21, 2018

Conversation

t3chguy
Copy link
Member

@t3chguy t3chguy commented Jun 20, 2018

first half of #1678

Fixes element-hq/element-web#5792

t3chguy added 3 commits June 21, 2018 00:33
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
@@ -510,6 +510,10 @@ module.exports = React.createClass({
const AddressSelector = sdk.getComponent("elements.AddressSelector");
this.scrollElement = null;

// Use set to avoid O(n*m) operation
const selectedAddresses = new Set(this.state.userList.map(({address}) => address));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should rename userList and selectedAddresses to selectedList and likewise rename queryList to suggestedList.

@t3chguy, wdyt? Worth the faff?

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

});

const queryList = this.state.queryList.filter(({address, addressType}) => {
return !selectedAddresses[addressType] || !selectedAddresses[addressType].has(address);
Copy link
Contributor

Choose a reason for hiding this comment

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

This would be easier to grok if it were !(condition and condition) imo. It should make it clearer that the first condition is a effectively a null-guard.

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

@lukebarnard1 lukebarnard1 assigned t3chguy and unassigned lukebarnard1 Jun 21, 2018
t3chguy added 2 commits June 21, 2018 12:13
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
@t3chguy t3chguy assigned lukebarnard1 and unassigned t3chguy Jun 21, 2018
@t3chguy t3chguy merged commit 26aec43 into develop Jun 21, 2018
@t3chguy t3chguy deleted the t3chguy/deduplicate_address_picker branch April 27, 2020 18:01
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants