Avoid flashing the room list skeletons on launch

On a cold launch the home screen appeared just before the cached rooms
published, briefly showing skeletons that were immediately replaced.

The home screen now starts in a new awaitingCachedRooms mode, keeping
the list blank while a cached room list is about to publish and falling
back to the skeletons after 500ms. Without a cache the skeletons show
straight away as before.
This commit is contained in:
Stefan Ceriu
2026-10-02 10:06:00 +03:00
parent 4b6953e80f
commit a50c80c179
5 changed files with 42 additions and 10 deletions
@@ -25,7 +25,7 @@ struct HomeScreenContent: View {
GeometryReader { geometry in
ScrollView {
switch context.viewState.roomListMode {
case .skeletons:
case .awaitingCachedRooms, .skeletons:
LazyVStack(spacing: 0) {
ForEach(context.viewState.visibleRooms) { room in
HomeScreenRoomCell(room: room, isSelected: false, mediaProvider: context.mediaProvider, action: context.send)
@@ -34,6 +34,8 @@ struct HomeScreenContent: View {
}
}
.disabled(true)
// Laid out but hidden while awaiting so the rooms replace it without a growing animation.
.opacity(context.viewState.roomListMode == .awaitingCachedRooms ? 0 : 1)
.accessibilityRepresentation {
Text(L10n.commonLoading)
}
@@ -103,7 +105,7 @@ struct HomeScreenContent: View {
}
}
.scrollDismissesKeyboard(.immediately)
.scrollDisabled(context.viewState.roomListMode == .skeletons)
.scrollDisabled(context.viewState.roomListMode == .skeletons || context.viewState.roomListMode == .awaitingCachedRooms)
.scrollBounceBehavior(context.viewState.roomListMode == .empty ? .basedOnSize : .automatic)
.animation(.elementDefault, value: context.viewState.roomListMode)
.animation(.none, value: context.viewState.visibleRooms)