Merge pull request #930 from Bilb/include-friend-search-result

Include friend search result #928
pull/950/head
Audric Ackermann 5 years ago committed by GitHub
commit 82b02f84ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -75,6 +75,10 @@ export class SearchResults extends React.Component<Props> {
))} ))}
</div> </div>
) : null} ) : null}
{haveFriends
? this.renderContacts(i18n('friendsHeader'), friends, true)
: null}
{haveMessages ? ( {haveMessages ? (
<div className="module-search-results__messages"> <div className="module-search-results__messages">
{hideMessagesHeader ? null : ( {hideMessagesHeader ? null : (
@ -95,4 +99,26 @@ export class SearchResults extends React.Component<Props> {
</div> </div>
); );
} }
private renderContacts(
header: string,
items: Array<ConversationListItemPropsType>,
friends?: boolean
) {
const { i18n, openConversation } = this.props;
return (
<div className="module-search-results__contacts">
<div className="module-search-results__contacts-header">{header}</div>
{items.map(contact => (
<ConversationListItem
key={contact.phoneNumber}
isFriend={friends}
{...contact}
onClick={openConversation}
i18n={i18n}
/>
))}
</div>
);
}
} }

@ -132,11 +132,16 @@ export class LeftPaneMessageSection extends React.Component<Props, any> {
public renderList(): JSX.Element | Array<JSX.Element | null> { public renderList(): JSX.Element | Array<JSX.Element | null> {
const { openConversationInternal, searchResults } = this.props; const { openConversationInternal, searchResults } = this.props;
const friends =
(searchResults &&
searchResults.contacts.filter(contact => contact.isFriend)) ||
[];
if (searchResults) { if (searchResults) {
return ( return (
<SearchResults <SearchResults
{...searchResults} {...searchResults}
friends={friends}
openConversation={openConversationInternal} openConversation={openConversationInternal}
i18n={window.i18n} i18n={window.i18n}
/> />

@ -214,7 +214,6 @@ async function queryConversationsAndContacts(
conversations.push(conversation.id); conversations.push(conversation.id);
} }
} }
// Inject synthetic Note to Self entry if query matches localized 'Note to Self' // Inject synthetic Note to Self entry if query matches localized 'Note to Self'
if (noteToSelf.indexOf(providedQuery.toLowerCase()) !== -1) { if (noteToSelf.indexOf(providedQuery.toLowerCase()) !== -1) {
// ensure that we don't have duplicates in our results // ensure that we don't have duplicates in our results

Loading…
Cancel
Save