You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-16 16:42:01 +03:00
Moved the isValidAddress method to the Invite utilty object
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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");
|
||||
|
Reference in New Issue
Block a user