mirror of
https://github.com/neon443/StickerSlack.git
synced 2026-11-30 12:44:51 +00:00
fix downloading gifs and improved search by making it interactive and fix the mamory leak hopefully
This commit is contained in:
2 files changed
+9
-8
No files matched your search
@@ -17,7 +17,7 @@ struct Gif: StickerProtocol {
|
|||||||
let split = urlString.split(separator: ".")
|
let split = urlString.split(separator: ".")
|
||||||
let fileExtension = ".\(split.last ?? "png")"
|
let fileExtension = ".\(split.last ?? "png")"
|
||||||
|
|
||||||
return EmojiHoarder.container.appendingPathComponent("gifs", conformingTo: .directory).absoluteString+id+fileExtension
|
return Hoarder.container.absoluteString+id+fileExtension
|
||||||
}
|
}
|
||||||
var remoteImageURL: URL
|
var remoteImageURL: URL
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,9 @@ struct SearchView: View {
|
|||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
NavigationStack {
|
NavigationStack {
|
||||||
List() {
|
List {
|
||||||
Text("\(searchResult.count) Result\(searchResult.count.plural)")
|
Text("\(searchResult.count) Result\(searchResult.count.plural)")
|
||||||
|
.contentTransition(.numericText())
|
||||||
ForEach(searchResult, id: \.self) { name in
|
ForEach(searchResult, id: \.self) { name in
|
||||||
StickerRow(hoarder: hoarder, emoji: hoarder.trie.dict[name]!)
|
StickerRow(hoarder: hoarder, emoji: hoarder.trie.dict[name]!)
|
||||||
}
|
}
|
||||||
@@ -25,17 +26,17 @@ struct SearchView: View {
|
|||||||
}
|
}
|
||||||
.searchable(text: $searchTerm)
|
.searchable(text: $searchTerm)
|
||||||
.onChange(of: searchTerm) { _ in
|
.onChange(of: searchTerm) { _ in
|
||||||
if searchTerm.isEmpty { searchResult = [] }
|
|
||||||
}
|
|
||||||
.onSubmit(of: .search) {
|
|
||||||
guard !searchTerm.isEmpty else {
|
guard !searchTerm.isEmpty else {
|
||||||
currentSearch?.cancel()
|
currentSearch?.cancel()
|
||||||
searchResult = []
|
withAnimation { searchResult = [] }
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if currentSearch != nil { currentSearch?.cancel() }
|
if currentSearch != nil {
|
||||||
currentSearch = Task.detached {
|
withAnimation { currentSearch?.cancel() }
|
||||||
|
}
|
||||||
|
currentSearch = Task {
|
||||||
let result = await hoarder.trie.search(for: searchTerm)
|
let result = await hoarder.trie.search(for: searchTerm)
|
||||||
|
guard !Task.isCancelled else { return }
|
||||||
await MainActor.run {
|
await MainActor.run {
|
||||||
withAnimation(.snappy) {
|
withAnimation(.snappy) {
|
||||||
searchResult = result
|
searchResult = result
|
||||||
|
|||||||