From de4d984ded05d9bd156c99bcdcff02146969ae21 Mon Sep 17 00:00:00 2001 From: miruka Date: Mon, 19 Aug 2019 18:25:00 -0400 Subject: [PATCH] Use smart case for filters --- TODO.md | 2 -- src/qml/utils.js | 11 +++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index 3cbea451..98ed6cd7 100644 --- a/TODO.md +++ b/TODO.md @@ -1,7 +1,5 @@ - Refactoring - Don't show the highlight rectangle sliding when clicking room - - Make room loading faster - - Filter smart case - Make all icon SVG files white/black, since we can now use ColorOverlay - Make the icon blue in EditAccount when hovering and no avatar set diff --git a/src/qml/utils.js b/src/qml/utils.js index 35a2a7a4..385a240b 100644 --- a/src/qml/utils.js +++ b/src/qml/utils.js @@ -74,12 +74,15 @@ function processedEventText(ev) { function filterMatches(filter, text) { - filter = filter.toLowerCase() - text = text.toLowerCase() + let filter_lower = filter.toLowerCase() - let words = filter.split(" ") + if (filter_lower == filter) { + // Consider case only if filter isn't all lowercase (smart case) + filter = filter_lower + text = text.toLowerCase() + } - for (let word of words) { + for (let word of filter.split(" ")) { if (word && ! text.includes(word)) { return false }