From a97e2e6ef21d9c45068bf58691c56a76750b411b Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Thu, 25 Jul 2019 21:49:22 +0100 Subject: [PATCH] clean up onPaste error handling in AddressPickerDialog Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/dialogs/AddressPickerDialog.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/views/dialogs/AddressPickerDialog.js b/src/components/views/dialogs/AddressPickerDialog.js index edb29181a9..63964a6ad6 100644 --- a/src/components/views/dialogs/AddressPickerDialog.js +++ b/src/components/views/dialogs/AddressPickerDialog.js @@ -457,6 +457,7 @@ module.exports = React.createClass({ _addAddressesToList: function(addressTexts) { const selectedList = this.state.selectedList.slice(); + let hasError = false; addressTexts.forEach((addressText) => { addressText = addressText.trim(); const addrType = getAddressType(addressText); @@ -467,8 +468,7 @@ module.exports = React.createClass({ }; if (!this.props.validAddressTypes.includes(addrType)) { - this.setState({ error: true }); - return null; + hasError = true; } else if (addrType === 'mx-user-id') { const user = MatrixClientPeg.get().getUser(addrObj.address); if (user) { @@ -492,9 +492,10 @@ module.exports = React.createClass({ selectedList, suggestedList: [], query: "", + error: hasError ? true : this.state.error, }); if (this._cancelThreepidLookup) this._cancelThreepidLookup(); - return selectedList; + return hasError ? null : selectedList; }, _lookupThreepid: function(medium, address) {