Add a Messages tab to global search

Split global search into Rooms and Messages tabs. The Messages tab lists
matching events with the room's name and avatar, a sender-prefixed preview,
rich media (image/video/audio/file) previews, and a loading indicator, then
paginates as you scroll. Queries are debounced and the previous one is
superseded so late results can't clobber a newer search.
This commit is contained in:
Stefan Ceriu
2026-07-02 13:25:56 +03:00
parent 5851100f07
commit 4fbfc87551
13 changed files with 727 additions and 81 deletions
@@ -15,9 +15,11 @@ enum SearchServiceProxyError: Error {
// sourcery: AutoMockable
protocol SearchServiceProxyProtocol {
var resultsPublisher: CurrentValuePublisher<[SearchServiceResult], Never> { get }
var paginationStatePublisher: CurrentValuePublisher<SearchServicePaginationState, Never> { get }
func setQuery(_ query: String) async -> Result<Void, SearchServiceProxyError>
/// Loads the next page of results. No-ops if a page is already loading or the end has been reached.
func paginate() async
}
@@ -29,3 +31,19 @@ struct SearchServiceResult {
let content: TimelineEventContent
let timestamp: Date
}
enum SearchServicePaginationState: Equatable {
case idle(endReached: Bool)
case loading
}
extension SearchServicePaginationState {
init(sdkState: MatrixRustSDK.SearchServicePaginationState) {
switch sdkState {
case .loading:
self = .loading
case .idle(let endReached):
self = .idle(endReached: endReached)
}
}
}