mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 21:33:26 +00:00
Room list service (#1138)
* Adopt the new RoomListService * Use client.roomListWithEncryption * Store the roomList so that it doesn't get dropped and create problems on the rust side * Use roomListService instead of old roomList client method * Added back documentation removed by mistake * Tweaks following code review, SDK bump
This commit is contained in:
@@ -26,7 +26,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
private let mediaLoader: MediaLoaderProtocol
|
||||
private let clientQueue: DispatchQueue
|
||||
|
||||
private var roomListService: RoomList?
|
||||
private var roomListService: RoomListService?
|
||||
private var roomListStateUpdateTaskHandle: TaskHandle?
|
||||
|
||||
var roomSummaryProvider: RoomSummaryProviderProtocol?
|
||||
@@ -227,8 +227,8 @@ class ClientProxy: ClientProxyProtocol {
|
||||
return nil
|
||||
}
|
||||
|
||||
if roomSummaryProvider.statePublisher.value != .fullyLoaded {
|
||||
_ = await roomSummaryProvider.statePublisher.values.first(where: { $0 == .fullyLoaded })
|
||||
if !roomSummaryProvider.statePublisher.value.isLoaded {
|
||||
_ = await roomSummaryProvider.statePublisher.values.first(where: { $0.isLoaded })
|
||||
}
|
||||
|
||||
(roomListItem, room) = await Task.dispatch(on: clientQueue) {
|
||||
@@ -366,7 +366,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
}
|
||||
|
||||
do {
|
||||
let roomListService = try client.roomList()
|
||||
let roomListService = try client.roomListServiceWithEncryption()
|
||||
roomListStateUpdateTaskHandle = roomListService.state(listener: RoomListStateListenerProxy { [weak self] state in
|
||||
guard let self else { return }
|
||||
MXLog.info("Received room list update: \(state)")
|
||||
@@ -379,9 +379,12 @@ class ClientProxy: ClientProxyProtocol {
|
||||
// The invites are available only when entering `running`
|
||||
if state == .running {
|
||||
Task {
|
||||
// Subscribe to invites later as the underlying SlidingSync list is only added when entering AllRooms
|
||||
await self.inviteSummaryProvider?.subscribeIfNecessary(entriesFunction: roomListService.invites(listener:),
|
||||
entriesLoadingStateFunction: nil)
|
||||
do {
|
||||
// Subscribe to invites later as the underlying SlidingSync list is only added when entering AllRooms
|
||||
try await self.inviteSummaryProvider?.setRoomList(roomListService.invites())
|
||||
} catch {
|
||||
MXLog.error("Failed configuring invites room list with error: \(error)")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -397,8 +400,7 @@ class ClientProxy: ClientProxyProtocol {
|
||||
eventStringBuilder: RoomEventStringBuilder(stateEventStringBuilder: RoomStateEventStringBuilder(userID: userID)),
|
||||
name: "AllRooms")
|
||||
|
||||
await roomSummaryProvider?.subscribeIfNecessary(entriesFunction: roomListService.entries(listener:),
|
||||
entriesLoadingStateFunction: roomListService.entriesLoadingState(listener:))
|
||||
try await roomSummaryProvider?.setRoomList(roomListService.allRooms())
|
||||
|
||||
inviteSummaryProvider = RoomSummaryProvider(roomListService: roomListService,
|
||||
eventStringBuilder: RoomEventStringBuilder(stateEventStringBuilder: RoomStateEventStringBuilder(userID: userID)),
|
||||
@@ -437,14 +439,14 @@ extension ClientProxy: MediaLoaderProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
private class RoomListStateListenerProxy: RoomListStateListener {
|
||||
private let onUpdateClosure: (RoomListState) -> Void
|
||||
private class RoomListStateListenerProxy: RoomListServiceStateListener {
|
||||
private let onUpdateClosure: (RoomListServiceState) -> Void
|
||||
|
||||
init(_ onUpdateClosure: @escaping (RoomListState) -> Void) {
|
||||
init(_ onUpdateClosure: @escaping (RoomListServiceState) -> Void) {
|
||||
self.onUpdateClosure = onUpdateClosure
|
||||
}
|
||||
|
||||
func onUpdate(state: RoomListState) {
|
||||
func onUpdate(state: RoomListServiceState) {
|
||||
onUpdateClosure(state)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user