mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
updated search algorithm to use previous search result to speed up when typing things out, eg
before
"a": 47k -> 25k emojis
"ab": 47k -> ~850
after
"a": 47k -> 25k
"ab" 25k -> ~850
also sort search results
using a Task again
added a ui thingy for no downloaded emojis
This commit is contained in:
4 files changed
+31
-15
No files matched your search
@@ -42,12 +42,17 @@ class Trie: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
func search(for query: String) -> [String] {
|
||||
func search(for query: String, previousQuery: String?, previousResult: Set<String>?) -> [String] {
|
||||
var result: Set<String> = wordlist
|
||||
if let previousQuery,
|
||||
let previousResult,
|
||||
query.hasPrefix(previousQuery) {
|
||||
result = previousResult
|
||||
}
|
||||
for word in query.split(separator: " ") {
|
||||
result = result.filter { $0.localizedCaseInsensitiveContains(word) }
|
||||
}
|
||||
return Array(result)
|
||||
return Array(result).sorted()
|
||||
}
|
||||
|
||||
func search(exactly query: String) -> Bool {
|
||||
|
||||