mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 12:07:55 +00:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user