Make the SpaceRoomListProxy publish its SpaceRoomProxy updates. (#4607)

Also removes an unused `parent` parameter that was missed when removing the parent name and includes some regenerated snapshots that were missed in the last PR.
This commit is contained in:
Doug
2025-10-09 17:22:43 +01:00
committed by GitHub
parent c588ace336
commit f01f31954d
24 changed files with 91 additions and 63 deletions
@@ -9,8 +9,15 @@ import Combine
import MatrixRustSDK
class SpaceRoomListProxy: SpaceRoomListProxyProtocol {
var id: String { spaceRoomProxyPublisher.value.id }
private let spaceRoomList: SpaceRoomListProtocol
let spaceRoomProxy: SpaceRoomProxyProtocol
private var spaceRoomProxyHandle: TaskHandle?
private let spaceRoomProxySubject: CurrentValueSubject<SpaceRoomProxyProtocol, Never>
var spaceRoomProxyPublisher: CurrentValuePublisher<SpaceRoomProxyProtocol, Never> {
spaceRoomProxySubject.asCurrentValuePublisher()
}
private var spaceRoomsHandle: TaskHandle?
private let spaceRoomsSubject = CurrentValueSubject<[SpaceRoomProxyProtocol], Never>([])
@@ -25,7 +32,7 @@ class SpaceRoomListProxy: SpaceRoomListProxyProtocol {
guard let spaceRoom = spaceRoomList.space() else { throw SpaceRoomListProxyError.missingSpace }
self.spaceRoomList = spaceRoomList
spaceRoomProxy = SpaceRoomProxy(spaceRoom: spaceRoom)
spaceRoomProxySubject = .init(SpaceRoomProxy(spaceRoom: spaceRoom))
let paginationStateSubject = CurrentValueSubject<SpaceRoomListPaginationState, Never>(spaceRoomList.paginationState())
paginationStatePublisher = paginationStateSubject.asCurrentValuePublisher()
@@ -37,6 +44,11 @@ class SpaceRoomListProxy: SpaceRoomListProxyProtocol {
spaceRoomsHandle = spaceRoomList.subscribeToRoomUpdate(listener: SDKListener { [weak self] updates in
self?.handleUpdates(updates)
})
spaceRoomProxyHandle = spaceRoomList.subscribeToSpaceUpdates(listener: SDKListener { [weak self] spaceRoom in
guard let spaceRoom else { return }
self?.spaceRoomProxySubject.send(SpaceRoomProxy(spaceRoom: spaceRoom))
})
}
func paginate() async {
@@ -14,8 +14,9 @@ enum SpaceRoomListProxyError: Error {
// sourcery: AutoMockable
protocol SpaceRoomListProxyProtocol {
var spaceRoomProxy: SpaceRoomProxyProtocol { get }
var id: String { get }
var spaceRoomProxyPublisher: CurrentValuePublisher<SpaceRoomProxyProtocol, Never> { get }
var spaceRoomsPublisher: CurrentValuePublisher<[SpaceRoomProxyProtocol], Never> { get }
var paginationStatePublisher: CurrentValuePublisher<SpaceRoomListPaginationState, Never> { get }
@@ -30,7 +30,7 @@ class SpaceServiceProxy: SpaceServiceProxyProtocol {
})
}
func spaceRoomList(spaceID: String, parent: SpaceRoomProxyProtocol?) async -> Result<SpaceRoomListProxyProtocol, SpaceServiceProxyError> {
func spaceRoomList(spaceID: String) async -> Result<SpaceRoomListProxyProtocol, SpaceServiceProxyError> {
do {
return try await .success(SpaceRoomListProxy(spaceService.spaceRoomList(spaceId: spaceID)))
} catch {
@@ -16,6 +16,6 @@ enum SpaceServiceProxyError: Error {
protocol SpaceServiceProxyProtocol {
var joinedSpacesPublisher: CurrentValuePublisher<[SpaceRoomProxyProtocol], Never> { get }
func spaceRoomList(spaceID: String, parent: SpaceRoomProxyProtocol?) async -> Result<SpaceRoomListProxyProtocol, SpaceServiceProxyError>
func spaceRoomList(spaceID: String) async -> Result<SpaceRoomListProxyProtocol, SpaceServiceProxyError>
func leaveSpace(spaceID: String) async -> Result<LeaveSpaceHandleProxy, SpaceServiceProxyError>
}