diff --git a/ts/components/SearchResults.tsx b/ts/components/SearchResults.tsx index fc1de4c8f..cd6f1c04b 100644 --- a/ts/components/SearchResults.tsx +++ b/ts/components/SearchResults.tsx @@ -75,6 +75,10 @@ export class SearchResults extends React.Component { ))} ) : null} + {haveFriends + ? this.renderContacts(i18n('friendsHeader'), friends, true) + : null} + {haveMessages ? (
{hideMessagesHeader ? null : ( @@ -95,4 +99,26 @@ export class SearchResults extends React.Component {
); } + private renderContacts( + header: string, + items: Array, + friends?: boolean + ) { + const { i18n, openConversation } = this.props; + + return ( +
+
{header}
+ {items.map(contact => ( + + ))} +
+ ); + } } diff --git a/ts/components/session/LeftPaneMessageSection.tsx b/ts/components/session/LeftPaneMessageSection.tsx index 9841257ea..e29b942b1 100644 --- a/ts/components/session/LeftPaneMessageSection.tsx +++ b/ts/components/session/LeftPaneMessageSection.tsx @@ -132,11 +132,16 @@ export class LeftPaneMessageSection extends React.Component { public renderList(): JSX.Element | Array { const { openConversationInternal, searchResults } = this.props; + const friends = + (searchResults && + searchResults.contacts.filter(contact => contact.isFriend)) || + []; if (searchResults) { return ( diff --git a/ts/state/ducks/search.ts b/ts/state/ducks/search.ts index f5e38b259..c92fdd814 100644 --- a/ts/state/ducks/search.ts +++ b/ts/state/ducks/search.ts @@ -172,7 +172,7 @@ async function queryConversationsAndContacts( providedQuery: string, options: SearchOptions ) { - const { ourNumber, noteToSelf, isSecondaryDevice } = options; + const { ourNumber, isSecondaryDevice } = options; const query = providedQuery.replace(/[+-.()]*/g, ''); const searchResults: Array = await searchConversations( @@ -193,8 +193,8 @@ async function queryConversationsAndContacts( ); // Split into two groups - active conversations and items just from address book - let conversations: Array = []; - let contacts: Array = []; + const conversations: Array = []; + const contacts: Array = []; const max = searchResults.length; for (let i = 0; i < max; i += 1) { const conversation = searchResults[i]; @@ -215,15 +215,6 @@ async function queryConversationsAndContacts( } } - // Inject synthetic Note to Self entry if query matches localized 'Note to Self' - if (noteToSelf.indexOf(providedQuery.toLowerCase()) !== -1) { - // ensure that we don't have duplicates in our results - contacts = contacts.filter(id => id !== ourNumber); - conversations = conversations.filter(id => id !== ourNumber); - - contacts.unshift(ourNumber); - } - return { conversations, contacts }; }