mirror of
https://github.com/element-hq/element-x-ios.git
synced 2025-03-11 13:59:13 +00:00
Fix room list service cold cache support. Make sure we dispatch the initial room list and use it for computing the home screen state
This commit is contained in:
parent
f649d362f5
commit
77061c4d7e
@ -79,13 +79,16 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
return
|
||||
}
|
||||
|
||||
roomSummaryProvider.statePublisher
|
||||
// Combine together the state and the room list to correctly compute the view state if
|
||||
// data is present in the room list "cold cache"
|
||||
Publishers.CombineLatest(roomSummaryProvider.statePublisher,
|
||||
roomSummaryProvider.roomListPublisher)
|
||||
.receive(on: DispatchQueue.main)
|
||||
.sink { [weak self] state in
|
||||
.sink { [weak self] state, rooms in
|
||||
guard let self else { return }
|
||||
|
||||
let isLoadingData = !state.isLoaded
|
||||
let hasNoRooms = (state.isLoaded && state.totalNumberOfRooms == 0)
|
||||
let isLoadingData = !state.isLoaded && rooms.isEmpty
|
||||
let hasNoRooms = (state.isLoaded && state.totalNumberOfRooms == 0 && rooms.isEmpty)
|
||||
|
||||
var roomListMode = self.state.roomListMode
|
||||
if isLoadingData {
|
||||
|
@ -85,6 +85,9 @@ class RoomSummaryProvider: RoomSummaryProviderProtocol {
|
||||
buildSummaryForRoomListEntry(roomListEntry)
|
||||
}
|
||||
|
||||
// Manually call it here as the didSet doesn't work from constructors
|
||||
roomListSubject.send(rooms)
|
||||
|
||||
let stateUpdatesSubscriptionResult = try roomList.loadingState(listener: RoomListStateObserver { [weak self] state in
|
||||
guard let self else { return }
|
||||
MXLog.info("\(name): Received state update: \(state)")
|
||||
|
Loading…
x
Reference in New Issue
Block a user