mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-02 03:06:37 +00:00
Set the room list mode synchronously on a warm launch
The room summary provider subscription only delivers its current state through an async main queue hop, which can end up queued behind the first render. On a warm launch, where the cached rooms have already been published before the home screen exists, that leaves the skeletons up for the whole duration. Read the current state at the end of init instead, alongside the rooms which were already being read there.
This commit is contained in:
@@ -176,6 +176,14 @@ class HomeScreenViewModel: HomeScreenViewModelType, HomeScreenViewModelProtocol
|
||||
setupRoomListSubscriptions()
|
||||
|
||||
updateRooms()
|
||||
|
||||
// The subscription above only delivers the current state through an async main queue
|
||||
// hop, which can end up queued behind the first render and leave the skeletons up on a
|
||||
// warm launch, where the provider has already published the cached rooms.
|
||||
if let roomSummaryProvider {
|
||||
updateRoomListMode(with: roomSummaryProvider.statePublisher.value,
|
||||
hasRooms: !roomSummaryProvider.roomListPublisher.value.isEmpty)
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Public
|
||||
|
||||
@@ -384,6 +384,14 @@ final class HomeScreenViewModelTests {
|
||||
|
||||
enum InviteType { case rooms, spaces }
|
||||
|
||||
@Test
|
||||
func roomListModeIsSetSynchronouslyOnAWarmLaunch() {
|
||||
setupViewModel()
|
||||
|
||||
// No awaiting, the mode must not need the subscription's async delivery.
|
||||
#expect(context.viewState.roomListMode == .rooms)
|
||||
}
|
||||
|
||||
@Test
|
||||
func roomListModeWaitsForTheRoomsToPublish() async throws {
|
||||
let (roomListSubject, stateSubject) = setupViewModelWithManualProvider()
|
||||
|
||||
Reference in New Issue
Block a user