From 7a86a68c22eb134656bd03b7e7a1989891ba5346 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Wed, 4 Mar 2020 14:05:05 +1100 Subject: [PATCH] enable back note to self in search result --- ts/state/ducks/search.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ts/state/ducks/search.ts b/ts/state/ducks/search.ts index c92fdd814..194823a79 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, isSecondaryDevice } = options; + const { ourNumber, noteToSelf, 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 - const conversations: Array = []; - const contacts: Array = []; + let conversations: Array = []; + let contacts: Array = []; const max = searchResults.length; for (let i = 0; i < max; i += 1) { const conversation = searchResults[i]; @@ -214,6 +214,14 @@ async function queryConversationsAndContacts( conversations.push(conversation.id); } } + // 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 }; }