fix downloading gifs and improved search by making it interactive and fix the mamory leak hopefully

This commit is contained in:
neon443 committed 2026-03-19 09:26:21 +00:00
1 parent ca30343e79
commit 1e72658f38
2 files changed
+9 -8

No files matched your search

+1 -1
View File
@@ -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
+8 -7
View File
@@ -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
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.