Merge pull request #3076 from matrix-org/t3chguy/fix_community_add_room
Fix AddressPickerDialog adding wrong entry to selected list case
This commit is contained in:
commit
6daf5a1d9b
1 changed files with 12 additions and 8 deletions
|
@ -205,7 +205,7 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
onSelected: function(index) {
|
onSelected: function(index) {
|
||||||
const selectedList = this.state.selectedList.slice();
|
const selectedList = this.state.selectedList.slice();
|
||||||
selectedList.push(this.state.suggestedList[index]);
|
selectedList.push(this._getFilteredSuggestions()[index]);
|
||||||
this.setState({
|
this.setState({
|
||||||
selectedList,
|
selectedList,
|
||||||
suggestedList: [],
|
suggestedList: [],
|
||||||
|
@ -526,12 +526,7 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
_getFilteredSuggestions: function() {
|
||||||
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
|
||||||
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
|
|
||||||
const AddressSelector = sdk.getComponent("elements.AddressSelector");
|
|
||||||
this.scrollElement = null;
|
|
||||||
|
|
||||||
// map addressType => set of addresses to avoid O(n*m) operation
|
// map addressType => set of addresses to avoid O(n*m) operation
|
||||||
const selectedAddresses = {};
|
const selectedAddresses = {};
|
||||||
this.state.selectedList.forEach(({address, addressType}) => {
|
this.state.selectedList.forEach(({address, addressType}) => {
|
||||||
|
@ -540,9 +535,16 @@ module.exports = React.createClass({
|
||||||
});
|
});
|
||||||
|
|
||||||
// Filter out any addresses in the above already selected addresses (matching both type and address)
|
// Filter out any addresses in the above already selected addresses (matching both type and address)
|
||||||
const filteredSuggestedList = this.state.suggestedList.filter(({address, addressType}) => {
|
return this.state.suggestedList.filter(({address, addressType}) => {
|
||||||
return !(selectedAddresses[addressType] && selectedAddresses[addressType].has(address));
|
return !(selectedAddresses[addressType] && selectedAddresses[addressType].has(address));
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
const BaseDialog = sdk.getComponent('views.dialogs.BaseDialog');
|
||||||
|
const DialogButtons = sdk.getComponent('views.elements.DialogButtons');
|
||||||
|
const AddressSelector = sdk.getComponent("elements.AddressSelector");
|
||||||
|
this.scrollElement = null;
|
||||||
|
|
||||||
const query = [];
|
const query = [];
|
||||||
// create the invite list
|
// create the invite list
|
||||||
|
@ -574,6 +576,8 @@ module.exports = React.createClass({
|
||||||
</textarea>,
|
</textarea>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const filteredSuggestedList = this._getFilteredSuggestions();
|
||||||
|
|
||||||
let error;
|
let error;
|
||||||
let addressSelector;
|
let addressSelector;
|
||||||
if (this.state.error) {
|
if (this.state.error) {
|
||||||
|
|
Loading…
Reference in a new issue