enable back note to self in search result

pull/930/head
Audric Ackermann 6 years ago
parent 0528a4c8ac
commit 7a86a68c22
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -172,7 +172,7 @@ async function queryConversationsAndContacts(
providedQuery: string, providedQuery: string,
options: SearchOptions options: SearchOptions
) { ) {
const { ourNumber, isSecondaryDevice } = options; const { ourNumber, noteToSelf, isSecondaryDevice } = options;
const query = providedQuery.replace(/[+-.()]*/g, ''); const query = providedQuery.replace(/[+-.()]*/g, '');
const searchResults: Array<ConversationType> = await searchConversations( const searchResults: Array<ConversationType> = await searchConversations(
@ -193,8 +193,8 @@ async function queryConversationsAndContacts(
); );
// Split into two groups - active conversations and items just from address book // Split into two groups - active conversations and items just from address book
const conversations: Array<string> = []; let conversations: Array<string> = [];
const contacts: Array<string> = []; let contacts: Array<string> = [];
const max = searchResults.length; const max = searchResults.length;
for (let i = 0; i < max; i += 1) { for (let i = 0; i < max; i += 1) {
const conversation = searchResults[i]; const conversation = searchResults[i];
@ -214,6 +214,14 @@ async function queryConversationsAndContacts(
conversations.push(conversation.id); 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 }; return { conversations, contacts };
} }

Loading…
Cancel
Save