Use then, catch, done and display any errors that occur during search
This commit is contained in:
parent
3b6599dcdc
commit
68ddf35db4
1 changed files with 12 additions and 5 deletions
|
@ -61,6 +61,8 @@ module.exports = React.createClass({
|
||||||
|
|
||||||
// Whether a search is ongoing
|
// Whether a search is ongoing
|
||||||
busy: false,
|
busy: false,
|
||||||
|
// An error message generated during the user directory search
|
||||||
|
searchError: null,
|
||||||
// The query being searched for
|
// The query being searched for
|
||||||
query: "",
|
query: "",
|
||||||
// List of AddressTile.InviteAddressType objects representing
|
// List of AddressTile.InviteAddressType objects representing
|
||||||
|
@ -181,6 +183,7 @@ module.exports = React.createClass({
|
||||||
this.setState({
|
this.setState({
|
||||||
busy: true,
|
busy: true,
|
||||||
query,
|
query,
|
||||||
|
searchError: null,
|
||||||
});
|
});
|
||||||
MatrixClientPeg.get().searchUserDirectory({
|
MatrixClientPeg.get().searchUserDirectory({
|
||||||
term: query,
|
term: query,
|
||||||
|
@ -222,7 +225,12 @@ module.exports = React.createClass({
|
||||||
}, () => {
|
}, () => {
|
||||||
this.addressSelector.moveSelectionTop();
|
this.addressSelector.moveSelectionTop();
|
||||||
});
|
});
|
||||||
}).finally(() => {
|
}).catch((err) => {
|
||||||
|
console.error('Error whilst searching user directory: ', err);
|
||||||
|
this.setState({
|
||||||
|
searchError: err.errcode ? err.message : _t('Something went wrong!'),
|
||||||
|
});
|
||||||
|
}).done(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
busy: false,
|
busy: false,
|
||||||
});
|
});
|
||||||
|
@ -232,6 +240,7 @@ module.exports = React.createClass({
|
||||||
this.setState({
|
this.setState({
|
||||||
queryList: [],
|
queryList: [],
|
||||||
query: "",
|
query: "",
|
||||||
|
searchError: null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -494,6 +503,8 @@ module.exports = React.createClass({
|
||||||
let addressSelector;
|
let addressSelector;
|
||||||
if (this.state.error) {
|
if (this.state.error) {
|
||||||
error = <div className="mx_ChatInviteDialog_error">{_t("You have entered an invalid contact. Try using their Matrix ID or email address.")}</div>;
|
error = <div className="mx_ChatInviteDialog_error">{_t("You have entered an invalid contact. Try using their Matrix ID or email address.")}</div>;
|
||||||
|
} else if (this.state.searchError) {
|
||||||
|
error = <div className="mx_ChatInviteDialog_error">{this.state.searchError}</div>;
|
||||||
} else if (
|
} else if (
|
||||||
this.state.query.length > 0 &&
|
this.state.query.length > 0 &&
|
||||||
this.state.queryList.length === 0 &&
|
this.state.queryList.length === 0 &&
|
||||||
|
@ -501,15 +512,11 @@ module.exports = React.createClass({
|
||||||
) {
|
) {
|
||||||
error = <div className="mx_ChatInviteDialog_error">{_t("No results")}</div>;
|
error = <div className="mx_ChatInviteDialog_error">{_t("No results")}</div>;
|
||||||
} else {
|
} else {
|
||||||
const addressSelectorHeader = <div className="mx_ChatInviteDialog_addressSelectHeader">
|
|
||||||
{ _t("Searching known users") }
|
|
||||||
</div>;
|
|
||||||
addressSelector = (
|
addressSelector = (
|
||||||
<AddressSelector ref={(ref) => {this.addressSelector = ref;}}
|
<AddressSelector ref={(ref) => {this.addressSelector = ref;}}
|
||||||
addressList={ this.state.queryList }
|
addressList={ this.state.queryList }
|
||||||
onSelected={ this.onSelected }
|
onSelected={ this.onSelected }
|
||||||
truncateAt={ TRUNCATE_QUERY_LIST }
|
truncateAt={ TRUNCATE_QUERY_LIST }
|
||||||
header={ addressSelectorHeader }
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue