From de48da19dab9b9a22dc7ea9f1ca6d633eb2e3d2a Mon Sep 17 00:00:00 2001 From: Antonella Sgarlatta Date: Mon, 22 Feb 2021 13:35:50 -0300 Subject: [PATCH] feat: filter out only protected notes text from search --- src/screens/Notes/utils.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/screens/Notes/utils.ts b/src/screens/Notes/utils.ts index c5bda84f..ce6716bc 100644 --- a/src/screens/Notes/utils.ts +++ b/src/screens/Notes/utils.ts @@ -20,11 +20,7 @@ export function notePassesFilter( ) { let canShowArchived = showArchived; const canShowPinned = !hidePinned; - if ( - (note.archived && !canShowArchived) || - (note.pinned && !canShowPinned) || - (note.protected && filterText) - ) { + if ((note.archived && !canShowArchived) || (note.pinned && !canShowPinned)) { return false; } return noteMatchesQuery(note, filterText); @@ -39,7 +35,10 @@ function noteMatchesQuery(note: SNNote, query: string) { const lowercaseText = query.toLowerCase(); const quotedText = stringBetweenQuotes(lowercaseText); if (quotedText) { - return title.includes(quotedText) || text.includes(quotedText); + return ( + title.includes(quotedText) || + (!note.protected && text.includes(quotedText)) + ); } if (stringIsUuid(lowercaseText)) { return note.uuid === lowercaseText; @@ -51,7 +50,7 @@ function noteMatchesQuery(note: SNNote, query: string) { const matchesBody = words.every(word => { return text.indexOf(word) >= 0; }); - return matchesTitle || matchesBody; + return matchesTitle || (!note.protected && matchesBody); } function stringBetweenQuotes(text: string) {