mirror of
https://github.com/element-hq/element-web.git
synced 2024-11-30 23:31:28 +03:00
hide already chosen results from AddressPickerDialog
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
4dba23b81d
commit
bce87829b6
1 changed files with 7 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
Copyright 2017 New Vector Ltd
|
Copyright 2017, 2018 New Vector Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
|
@ -510,6 +510,10 @@ module.exports = React.createClass({
|
||||||
const AddressSelector = sdk.getComponent("elements.AddressSelector");
|
const AddressSelector = sdk.getComponent("elements.AddressSelector");
|
||||||
this.scrollElement = null;
|
this.scrollElement = null;
|
||||||
|
|
||||||
|
// Use set to avoid O(n*m) operation
|
||||||
|
const selectedAddresses = new Set(this.state.userList.map(({address}) => address));
|
||||||
|
const queryList = this.state.queryList.filter(({address}) => !selectedAddresses.has(address));
|
||||||
|
|
||||||
const query = [];
|
const query = [];
|
||||||
// create the invite list
|
// create the invite list
|
||||||
if (this.state.userList.length > 0) {
|
if (this.state.userList.length > 0) {
|
||||||
|
@ -561,16 +565,12 @@ module.exports = React.createClass({
|
||||||
</div>;
|
</div>;
|
||||||
} else if (this.state.searchError) {
|
} else if (this.state.searchError) {
|
||||||
error = <div className="mx_ChatInviteDialog_error">{ this.state.searchError }</div>;
|
error = <div className="mx_ChatInviteDialog_error">{ this.state.searchError }</div>;
|
||||||
} else if (
|
} else if (this.state.query.length > 0 && queryList.length === 0 && !this.state.busy) {
|
||||||
this.state.query.length > 0 &&
|
|
||||||
this.state.queryList.length === 0 &&
|
|
||||||
!this.state.busy
|
|
||||||
) {
|
|
||||||
error = <div className="mx_ChatInviteDialog_error">{ _t("No results") }</div>;
|
error = <div className="mx_ChatInviteDialog_error">{ _t("No results") }</div>;
|
||||||
} else {
|
} else {
|
||||||
addressSelector = (
|
addressSelector = (
|
||||||
<AddressSelector ref={(ref) => {this.addressSelector = ref;}}
|
<AddressSelector ref={(ref) => {this.addressSelector = ref;}}
|
||||||
addressList={this.state.queryList}
|
addressList={queryList}
|
||||||
showAddress={this.props.pickerType === 'user'}
|
showAddress={this.props.pickerType === 'user'}
|
||||||
onSelected={this.onSelected}
|
onSelected={this.onSelected}
|
||||||
truncateAt={TRUNCATE_QUERY_LIST}
|
truncateAt={TRUNCATE_QUERY_LIST}
|
||||||
|
|
Loading…
Reference in a new issue