From cba76d651a79a0084a0ad4ce8dfd7f36138b1f83 Mon Sep 17 00:00:00 2001 From: wmwragg Date: Tue, 13 Sep 2016 12:12:33 +0100 Subject: [PATCH] Moved the isValidAddress method to the Invite utilty object --- src/Invite.js | 17 +++++++++++++++++ .../views/dialogs/ChatInviteDialog.js | 19 +------------------ 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Invite.js b/src/Invite.js index 3b52d6a1f4..2c908628b6 100644 --- a/src/Invite.js +++ b/src/Invite.js @@ -43,3 +43,20 @@ export function inviteToRoom(roomId, addr) { throw new Error('Unsupported address'); } } + +export function isValidAddress(addr) { + // Check if the addr is a valid type + var addrType = this.getAddressType(addr); + if (addrType === "mx") { + let user = MatrixClientPeg.get().getUser(addr); + if (user) { + return true; + } else { + return false; + } + } else if (addrType === "email") { + return true; + } else { + return false; + } +} diff --git a/src/components/views/dialogs/ChatInviteDialog.js b/src/components/views/dialogs/ChatInviteDialog.js index bf4acf59d3..3cfe7303be 100644 --- a/src/components/views/dialogs/ChatInviteDialog.js +++ b/src/components/views/dialogs/ChatInviteDialog.js @@ -122,7 +122,7 @@ module.exports = React.createClass({ } else if (e.keyCode === 32 || e.keyCode === 188) { // space or comma e.stopPropagation(); e.preventDefault(); - if (this._isValidAddress(this.refs.textinput.value)) { + if (Invite.isValidAddress(this.refs.textinput.value)) { var inviteList = this.state.inviteList.slice(); inviteList.push(this.refs.textinput.value); this.setState({ @@ -271,23 +271,6 @@ module.exports = React.createClass({ return false; }, - _isValidAddress: function(addr) { - // Check if the addr is a valid type - var addrType = Invite.getAddressType(addr); - if (addrType === "mx") { - let user = MatrixClientPeg.get().getUser(addr); - if (user) { - return true; - } else { - return false; - } - } else if (addrType === "email") { - return true; - } else { - return false; - } - }, - render: function() { var TintableSvg = sdk.getComponent("elements.TintableSvg"); var AddressSelector = sdk.getComponent("elements.AddressSelector");