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 @@ -172,43 +172,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 @@ -134,6 +134,9 @@ ...AccountUserInfo, +disabled?: boolean, +notice?: string, - +alertText?: string, - +alertTitle?: string, + +alert?: { + +text: string, + +title: string, + }, + +avatar?: ?ClientAvatar, }; 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 @@ -52,7 +52,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 @@ -57,13 +57,12 @@ onSelect = () => { const { userInfo } = this.props; - if (!userInfo.alertText) { - const { alertText, alertTitle, notice, disabled, ...accountUserInfo } = - userInfo; + if (!userInfo.alert) { + const { alert, notice, disabled, ...accountUserInfo } = userInfo; this.props.onSelect(accountUserInfo); 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 @@ -111,7 +111,7 @@ const userItems = userListItemsWithENSNames.map( (userSearchResult: UserListItem) => { - const { alertTitle, alertText, notice, disabled, ...accountUserInfo } = + const { alert, notice, disabled, ...accountUserInfo } = userSearchResult; return (
  • @@ -124,7 +124,7 @@
    {userSearchResult.username}
    -
    {userSearchResult.alertTitle}
    +
    {userSearchResult.notice}
  • ); diff --git a/web/modals/components/add-members-item.react.js b/web/modals/components/add-members-item.react.js --- a/web/modals/components/add-members-item.react.js +++ b/web/modals/components/add-members-item.react.js @@ -17,7 +17,7 @@ function AddMemberItem(props: AddMembersItemProps): React.Node { const { userInfo, onClick, userAdded = false } = props; - const canBeAdded = !userInfo.alertText; + const canBeAdded = !userInfo.alert; const onClickCallback = React.useCallback(() => { if (!canBeAdded) { @@ -28,14 +28,14 @@ const action = React.useMemo(() => { if (!canBeAdded) { - return userInfo.alertTitle; + return userInfo.alert?.title; } if (userAdded) { return Remove; } else { return 'Add'; } - }, [canBeAdded, userAdded, userInfo.alertTitle]); + }, [canBeAdded, userAdded, userInfo.alert?.title]); return (