Files
element-x-ios/ElementX/Sources/Services/Search/SearchServiceProxyProtocol.swift
T
Stefan Ceriu 4fbfc87551 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.
2026-07-03 13:39:45 +03:00

50 lines
1.4 KiB
Swift

// Copyright 2025 Element Creations Ltd.
// Copyright 2025 New Vector Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
import Combine
import Foundation
import MatrixRustSDK
enum SearchServiceProxyError: Error {
case sdkError(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
}
struct SearchServiceResult {
let roomID: String
let eventID: String
let sender: TimelineItemSender
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)
}
}
}