diff --git a/lib/shared/search-utils.js b/lib/shared/search-utils.js --- a/lib/shared/search-utils.js +++ b/lib/shared/search-utils.js @@ -129,43 +129,51 @@ relationshipStatus, ...result }) => { - let notice, alertText, alertTitle; + let notice, alert; const username = result.username; if (blockedRelationshipsStatuses.has(relationshipStatus)) { notice = 'user is blocked'; - alertTitle = 'User is blocked'; - alertText = - `Before you add ${username} to this chat, ` + - 'you’ll need to unblock them. You can do this from the Block List ' + - 'in the Profile tab.'; + alert = { + title: 'User is blocked', + text: + `Before you add ${username} to this chat, ` + + 'you’ll need to unblock them. You can do this from the Block List ' + + 'in the Profile tab.', + }; } else if (!isMemberOfContainingThread && containingThreadInfo) { if (threadType !== threadTypes.SIDEBAR) { notice = 'not in community'; - alertTitle = 'Not in community'; - alertText = 'You can only add members of the community to this chat'; + alert = { + title: 'Not in community', + text: 'You can only add members of the community to this chat', + }; } else { notice = 'not in parent chat'; - alertTitle = 'Not in parent chat'; - alertText = 'You can only add members of the parent chat to a thread'; + alert = { + title: 'Not in parent chat', + text: 'You can only add members of the parent chat to a thread', + }; } } else if ( !containingThreadInfo && relationshipStatus !== userRelationshipStatus.FRIEND ) { notice = notFriendNotice; - alertTitle = 'Not a friend'; - alertText = - `Before you add ${username} to this chat, ` + - 'you’ll need to send them a friend request. ' + - 'You can do this from the Friend List in the Profile tab.'; + alert = { + title: 'Not a friend', + text: + `Before you add ${username} to this chat, ` + + 'you’ll need to send them a friend request. ' + + 'You can do this from the Friend List in the Profile tab.', + }; } else if (parentThreadInfo && !isMemberOfParentThread) { notice = 'not in parent chat'; } if (notice) { result = { ...result, notice }; } - if (alertTitle) { - result = { ...result, alertTitle, alertText }; + if (alert) { + result = { ...result, alert }; } return result; }, diff --git a/lib/types/user-types.js b/lib/types/user-types.js --- a/lib/types/user-types.js +++ b/lib/types/user-types.js @@ -71,6 +71,8 @@ +username: string, +disabled?: boolean, +notice?: string, - +alertText?: string, - +alertTitle?: string, + +alert?: { + title: string, + text: string, + }, }; diff --git a/native/chat/message-list-thread-search.react.js b/native/chat/message-list-thread-search.react.js --- a/native/chat/message-list-thread-search.react.js +++ b/native/chat/message-list-thread-search.react.js @@ -54,7 +54,7 @@ continue; } nonFriendsSet.add(searchResult.id); - const { alertText, alertTitle, ...rest } = searchResult; + const { alert, ...rest } = searchResult; userListItemsArr.push(rest); } return [userListItemsArr, nonFriendsSet]; diff --git a/native/components/user-list-user.react.js b/native/components/user-list-user.react.js --- a/native/components/user-list-user.react.js +++ b/native/components/user-list-user.react.js @@ -54,11 +54,11 @@ onSelect = () => { const { userInfo } = this.props; - if (!userInfo.alertText) { + if (!userInfo.alert) { this.props.onSelect(userInfo.id); return; } - Alert.alert(userInfo.alertTitle, userInfo.alertText, [{ text: 'OK' }], { + Alert.alert(userInfo.alert.title, userInfo.alert.text, [{ text: 'OK' }], { cancelable: true, }); }; diff --git a/web/chat/chat-thread-composer.react.js b/web/chat/chat-thread-composer.react.js --- a/web/chat/chat-thread-composer.react.js +++ b/web/chat/chat-thread-composer.react.js @@ -161,7 +161,9 @@ className={css.searchResultsButton} >