Files
element-x-ios/ElementX/Sources/Services/Room/RoomSummary/RoomSummaryProviderProtocol.swift
Copilot c41a38159b Only offer joined rooms in the forward and share pickers (#6255)
* Initial plan

* Offer only joined rooms in destination pickers

Co-authored-by: Velin92 <34335419+Velin92@users.noreply.github.com>

* Clean whitespace in share picker test

Co-authored-by: Velin92 <34335419+Velin92@users.noreply.github.com>

* Restrict the shared picker room list to joined rooms

The alternate room summary provider, which backs the forward, share and
Add rooms pickers and global search, now always includes the SDK's
joined filter in its base filter. This replaces the per-call joinedOnly
flags, so Add rooms no longer offers invited rooms or spaces and no
screen can forget the flag.

A filter set before the provider has its room list is now applied once
the list is set, instead of being reset to the default. The share picker
hit this on a cold launch from the share extension.

The forward and share pickers also hide upgraded rooms, matching the
Suggestions section. The SDK has no filter for these.

Also registers the share picker's test file in the project, fixes the
blank-line indentation SwiftFormat flagged, and re-records the picker
snapshots without the upgraded room.

* Check room membership for forwarding suggestions and search breadcrumbs

RoomSummary now has isJoined, built from the room's membership. The
forwarding suggestions and the search breadcrumbs used a missing
joinRequestType to mean joined, which is also the case for rooms that
have been left or banned from. It only worked because the room list's
base filter already drops those.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Velin92 <34335419+Velin92@users.noreply.github.com>
Co-authored-by: Mauro Romito <mauro.romito@element.io>
2026-10-02 12:44:33 +00:00

64 lines
1.8 KiB
Swift

//
// Copyright 2025 Element Creations Ltd.
// Copyright 2022-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 RoomSummaryProviderState {
case notLoaded
case loaded(totalNumberOfRooms: UInt)
var isLoaded: Bool {
switch self {
case .loaded:
return true
default:
return false
}
}
var totalNumberOfRooms: UInt? {
switch self {
case .loaded(let totalNumberOfRooms):
return totalNumberOfRooms
default:
return nil
}
}
}
enum RoomSummaryProviderFilter: Equatable {
/// Filters out everything
case excludeAll
/// Includes only the items that satisfy the predicate logic
case search(query: String)
/// Includes only what satisfies the filters used
case all(filters: Set<RoomListFilter>)
/// Include only rooms from the given that satisfy the given filters
case rooms(roomsIDs: Set<String>, filters: Set<RoomListFilter>)
}
// sourcery: AutoMockable
protocol StaticRoomSummaryProviderProtocol {
/// Publishes the current state the summary provider is finding itself in
var statePublisher: CurrentValuePublisher<RoomSummaryProviderState, Never> { get }
/// Publishes the currently available room summaries
var roomListPublisher: CurrentValuePublisher<[RoomSummary], Never> { get }
func setRoomList(_ roomList: RoomList)
}
// sourcery: AutoMockable
protocol RoomSummaryProviderProtocol: StaticRoomSummaryProviderProtocol {
func updateVisibleRange(_ range: Range<Int>)
func setFilter(_ filter: RoomSummaryProviderFilter)
}