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:
Stefan Ceriu
2026-08-18 16:07:34 +03:00
parent 8c9edd5ea9
commit e7787f4c3f
2 changed files with 16 additions and 0 deletions
@@ -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()