fix searching again

This commit is contained in:
Nihaal Sharma committed 2026-03-21 11:05:45 +00:00
1 parent 0c216bb800
commit 6e5cc2d845
3 files changed
+38 -17

No files matched your search

+2 -2
View File
@@ -15,8 +15,8 @@ struct BrowseView: View {
var body: some View { var body: some View {
List { List {
Picker("", selection: $browseWhat) { Picker("", selection: $browseWhat) {
ForEach(StickerType.allCases, id: \.self) { type in ForEach(StickerType.allCases) { type in
Text(type.description) Text(type.description).tag(type)
} }
} }
.pickerStyle(.segmented) .pickerStyle(.segmented)
+12 -12
View File
@@ -25,6 +25,18 @@ struct DownloadedView: View {
} }
var body: some View { var body: some View {
if emojiHoarder.downloadedStickers.isEmpty && gifHoarder.downloadedStickers.isEmpty {
VStack(alignment: .center) {
Image(systemName: "questionmark.app.dashed")
.resizable().scaledToFit()
.frame(width: 75, height: 75)
Text("No Downloaded Stickers")
.font(.title)
.bold()
Text("Download some Slack Emojis or GIFs to use in iMessage!")
.foregroundStyle(.gray)
}
}
GeometryReader { geo in GeometryReader { geo in
ScrollView { ScrollView {
let columns: Int = max(1, Int((geo.size.width - 2*spacing) / (minColWidth + spacing))) let columns: Int = max(1, Int((geo.size.width - 2*spacing) / (minColWidth + spacing)))
@@ -62,18 +74,6 @@ struct DownloadedView: View {
.padding(.horizontal, spacing) .padding(.horizontal, spacing)
} }
} }
if emojiHoarder.downloadedStickers.isEmpty && gifHoarder.downloadedStickers.isEmpty {
VStack(alignment: .center) {
Image(systemName: "questionmark.app.dashed")
.resizable().scaledToFit()
.frame(width: 75, height: 75)
Text("No Downloaded Stickers")
.font(.title)
.bold()
Text("Download some Slack Emojis or GIFs to use in iMessage!")
.foregroundStyle(.gray)
}
}
} }
} }
+24 -3
View File
@@ -15,8 +15,18 @@ struct SearchView: View {
@State var previousSearches: [String] = [] @State var previousSearches: [String] = []
@State var searchResult: [String] = [] @State var searchResult: [String] = []
@State var stickerType: StickerType = .slackEmoji
var body: some View { var body: some View {
NavigationStack { NavigationStack {
Picker("", selection: $stickerType) {
ForEach(StickerType.allCases) { type in
Text(type.description).tag(type)
}
}
.pickerStyle(.segmented)
switch stickerType {
case .slackEmoji:
List { List {
Text("\(searchResult.count) Result\(searchResult.count.plural)") Text("\(searchResult.count) Result\(searchResult.count.plural)")
.contentTransition(.numericText()) .contentTransition(.numericText())
@@ -24,21 +34,32 @@ struct SearchView: View {
StickerRow(hoarder: hoarder, emoji: hoarder.trie.dict[name]!) StickerRow(hoarder: hoarder, emoji: hoarder.trie.dict[name]!)
} }
} }
.fixedSize()
EmojiCollectionView(hoarder: hoarder, items: searchResult)
.id(searchResult)
case .giphyGifs:
Text("uhh")
}
} }
.searchable(text: $searchTerm) .searchable(text: $searchTerm)
.onChange(of: searchTerm) { new in .onChange(of: searchTerm) { new in
if currentSearch != nil { currentSearch?.cancel() } if currentSearch != nil { currentSearch?.cancel() }
defer { previousSearches.append("") }
guard !searchTerm.isEmpty else { guard !searchTerm.isEmpty else {
currentSearch?.cancel() currentSearch?.cancel()
searchResult = [] searchResult = []
previousSearches.append(searchTerm)
return return
} }
currentSearch = Task { currentSearch = Task.detached {
let result = hoarder.trie.search(for: searchTerm, previousQuery: previousSearches.last, previousResult: Set(searchResult)) let result = await hoarder.trie.search(
for: searchTerm,
previousQuery: previousSearches.last,
previousResult: Set(searchResult)
)
await MainActor.run { await MainActor.run {
withAnimation { withAnimation {
searchResult = result searchResult = result
previousSearches.append(searchTerm)
} }
} }
} }
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.