mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-10-31 16:24:11 +00:00
Only show joined rooms in the search results
Rooms the user is invited to, or has knocked on, are handled by the chats list and aren't somewhere search should lead. The search screen now asks the room summary provider for joined rooms only.
This commit is contained in:
@@ -183,7 +183,7 @@ class SearchScreenViewModel: SearchScreenViewModelType, SearchScreenViewModelPro
|
||||
switch mode {
|
||||
case .rooms:
|
||||
searchedQueries[mode] = searchQuery
|
||||
roomSummaryProvider.setFilter(.search(query: searchQuery))
|
||||
roomSummaryProvider.setFilter(.search(query: searchQuery, joinedOnly: true))
|
||||
case .messages:
|
||||
setQueryTask = Task { [weak self] in
|
||||
// Debounce message queries; superseded keystrokes cancel this before it commits.
|
||||
|
||||
@@ -68,6 +68,25 @@ struct SearchScreenViewModelTests {
|
||||
#expect(!searchService.setQueryCalled)
|
||||
}
|
||||
|
||||
@Test
|
||||
func searchingExcludesRoomsThatAreNotJoined() async throws {
|
||||
let roomSummaryProvider = RoomSummaryProviderMock(.init(state: .loaded(.mockRooms + .mockInvites)))
|
||||
let clientProxy = ClientProxyMock(.init())
|
||||
clientProxy.searchService = searchService
|
||||
let viewModel = SearchScreenViewModel(roomSummaryProvider: roomSummaryProvider,
|
||||
clientProxy: clientProxy,
|
||||
mediaProvider: MediaProviderMock(.init()),
|
||||
userIndicatorController: userIndicatorController,
|
||||
appSettings: appSettings)
|
||||
|
||||
let deferred = deferFulfillment(viewModel.context.observe(\.viewState.rooms)) { !$0.isEmpty }
|
||||
viewModel.context.searchQuery = "room"
|
||||
try await deferred.fulfill()
|
||||
|
||||
#expect(roomSummaryProvider.setFilterReceivedFilter == .search(query: "room", joinedOnly: true))
|
||||
#expect(!viewModel.context.viewState.rooms.contains { $0.title == "First room" })
|
||||
}
|
||||
|
||||
@Test
|
||||
func messageSearch() async throws {
|
||||
let deferred = deferFulfillment(setQuerySubject) { $0 == "Foundation" }
|
||||
|
||||
Reference in New Issue
Block a user