mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user