Skip to content

Commit

Permalink
Avoid search rate limit (#704)
Browse files Browse the repository at this point in the history
(cherry picked from commit c04d3c2)
  • Loading branch information
Sjmarf authored and boscojwho committed Nov 23, 2023
1 parent adeb83a commit eae5376
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Mlem/Views/Tabs/Search/SearchResultsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ struct SearchResultsView: View {
.padding(.top, 8)
SearchResultListView(showTypeLabel: searchModel.searchTab == .topResults)
}
.onChange(of: searchModel.searchText) { newValue in
.onReceive(
searchModel.$searchText
.debounce(for: .seconds(0.2), scheduler: DispatchQueue.main)
) { newValue in
if searchModel.previousSearchText != newValue {
if !newValue.isEmpty {
contentTracker.refresh(using: searchModel.performSearch)
Expand Down

0 comments on commit eae5376

Please sign in to comment.