Changeset View
Changeset View
Standalone View
Standalone View
lib/shared/search-utils.js
Show First 20 Lines • Show All 132 Lines • ▼ Show 20 Lines | ): UserListItem[] { | ||||
return sortedResults.map( | return sortedResults.map( | ||||
({ | ({ | ||||
isMemberOfContainingThread, | isMemberOfContainingThread, | ||||
isMemberOfParentThread, | isMemberOfParentThread, | ||||
relationshipStatus, | relationshipStatus, | ||||
...result | ...result | ||||
}) => { | }) => { | ||||
let notice, alertText, alertTitle; | let notice, alert; | ||||
const username = result.username; | const username = result.username; | ||||
if (blockedRelationshipsStatuses.has(relationshipStatus)) { | if (blockedRelationshipsStatuses.has(relationshipStatus)) { | ||||
notice = 'user is blocked'; | notice = 'user is blocked'; | ||||
alertTitle = 'User is blocked'; | alert = { | ||||
alertText = | title: 'User is blocked', | ||||
text: | |||||
`Before you add ${username} to this chat, ` + | `Before you add ${username} to this chat, ` + | ||||
'you’ll need to unblock them. You can do this from the Block List ' + | 'you’ll need to unblock them. You can do this from the Block List ' + | ||||
'in the Profile tab.'; | 'in the Profile tab.', | ||||
}; | |||||
} else if (!isMemberOfContainingThread && containingThreadInfo) { | } else if (!isMemberOfContainingThread && containingThreadInfo) { | ||||
if (threadType !== threadTypes.SIDEBAR) { | if (threadType !== threadTypes.SIDEBAR) { | ||||
notice = 'not in community'; | notice = 'not in community'; | ||||
alertTitle = 'Not in community'; | alert = { | ||||
alertText = 'You can only add members of the community to this chat'; | title: 'Not in community', | ||||
text: 'You can only add members of the community to this chat', | |||||
}; | |||||
} else { | } else { | ||||
notice = 'not in parent chat'; | notice = 'not in parent chat'; | ||||
alertTitle = 'Not in parent chat'; | alert = { | ||||
alertText = 'You can only add members of the parent chat to a thread'; | title: 'Not in parent chat', | ||||
text: 'You can only add members of the parent chat to a thread', | |||||
}; | |||||
} | } | ||||
} else if ( | } else if ( | ||||
!containingThreadInfo && | !containingThreadInfo && | ||||
relationshipStatus !== userRelationshipStatus.FRIEND | relationshipStatus !== userRelationshipStatus.FRIEND | ||||
) { | ) { | ||||
notice = notFriendNotice; | notice = notFriendNotice; | ||||
alertTitle = 'Not a friend'; | alert = { | ||||
alertText = | title: 'Not a friend', | ||||
text: | |||||
`Before you add ${username} to this chat, ` + | `Before you add ${username} to this chat, ` + | ||||
'you’ll need to send them a friend request. ' + | 'you’ll need to send them a friend request. ' + | ||||
'You can do this from the Friend List in the Profile tab.'; | 'You can do this from the Friend List in the Profile tab.', | ||||
}; | |||||
} else if (parentThreadInfo && !isMemberOfParentThread) { | } else if (parentThreadInfo && !isMemberOfParentThread) { | ||||
notice = 'not in parent chat'; | notice = 'not in parent chat'; | ||||
} | } | ||||
if (notice) { | if (notice) { | ||||
result = { ...result, notice }; | result = { ...result, notice }; | ||||
} | } | ||||
if (alertTitle) { | if (alert) { | ||||
result = { ...result, alertTitle, alertText }; | result = { ...result, alert }; | ||||
} | } | ||||
return result; | return result; | ||||
}, | }, | ||||
); | ); | ||||
} | } | ||||
export { getPotentialMemberItems, notFriendNotice }; | export { getPotentialMemberItems, notFriendNotice }; |