Add ability to invite contact by phone number

This commit is contained in:
Vlad Piersec 2020-01-29 10:00:00 +02:00 committed by Дамян Минков
parent 1b6c5a7141
commit ab5627212d
1 changed files with 44 additions and 13 deletions

View File

@ -271,6 +271,21 @@ class AddPeopleDialog extends AbstractAddPeopleDialog<Props, State> {
_parseQueryResults: (?Array<Object>) => Array<Object>;
/**
* Returns the avatar component for a user.
*
* @param {Object} user - The user
* @param {string} className - The CSS class for the avatar component
* @private
* @returns {ReactElement}
*/
_getAvatar(user, className = 'avatar-small') {
return (<Avatar
className = { className }
status = { user.status }
url = { user.avatar } />);
}
/**
* Processes results from requesting available numbers and people by munging
* each result into a format {@code MultiSelectAutocomplete} can use for
@ -283,24 +298,40 @@ class AddPeopleDialog extends AbstractAddPeopleDialog<Props, State> {
* search autocomplete.
*/
_parseQueryResults(response = []) {
const { t } = this.props;
const { t, _dialOutEnabled } = this.props;
const users = response.filter(item => item.type !== 'phone');
const userDisplayItems = users.map(user => {
return {
content: user.name,
elemBefore: <Avatar
className = { 'avatar-small' }
status = { user.status }
url = { user.avatar } />,
const userDisplayItems = [];
users.forEach(user => {
const { name, phone } = user;
const tagAvatar = this._getAvatar(user, 'avatar-xsmall');
const elemAvatar = this._getAvatar(user);
userDisplayItems.push({
content: name,
elemBefore: elemAvatar,
item: user,
tag: {
elemBefore: <Avatar
className = { 'avatar-xsmall' }
status = { user.status }
url = { user.avatar } />
elemBefore: tagAvatar
},
value: user.id || user.user_id
};
});
if (phone && _dialOutEnabled) {
userDisplayItems.push({
filterValues: [ name, phone ],
content: `${phone} (${name})`,
elemBefore: elemAvatar,
item: {
type: 'phone',
number: phone
},
tag: {
elemBefore: tagAvatar
},
value: phone
});
}
});
const numbers = response.filter(item => item.type === 'phone');