mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 06:55:59 +00:00
Set visible ranges on the home screen sliding sync view (#342)
* Set visible ranges on the home screen sliding sync view * Prevent the visible items from being updated while in search mode * Enable diffs on invalidations as they seem to fix duplicated events in the home screen room list * Promoted some diffing logs to info from verbose
This commit is contained in:
@@ -18,9 +18,10 @@ import SwiftUI
|
||||
|
||||
struct HomeScreen: View {
|
||||
@State private var showingLogoutConfirmation = false
|
||||
@ObservedObject var context: HomeScreenViewModel.Context
|
||||
@State private var visibleItemIdentifiers = Set<String>()
|
||||
@State private var scrollViewAdapter = ScrollViewAdapter()
|
||||
|
||||
// MARK: Views
|
||||
@ObservedObject var context: HomeScreenViewModel.Context
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
@@ -40,11 +41,19 @@ struct HomeScreen: View {
|
||||
} else {
|
||||
LazyVStack {
|
||||
ForEach(context.viewState.visibleRooms) { room in
|
||||
if room.isPlaceholder {
|
||||
HomeScreenRoomCell(room: room, context: context)
|
||||
.redacted(reason: .placeholder)
|
||||
} else {
|
||||
HomeScreenRoomCell(room: room, context: context)
|
||||
Group {
|
||||
if room.isPlaceholder {
|
||||
HomeScreenRoomCell(room: room, context: context)
|
||||
.redacted(reason: .placeholder)
|
||||
} else {
|
||||
HomeScreenRoomCell(room: room, context: context)
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
visibleItemIdentifiers.insert(room.id)
|
||||
}
|
||||
.onDisappear {
|
||||
visibleItemIdentifiers.remove(room.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,6 +61,10 @@ struct HomeScreen: View {
|
||||
.searchable(text: $context.searchQuery)
|
||||
}
|
||||
}
|
||||
.introspectScrollView { scrollView in
|
||||
guard scrollView != scrollViewAdapter.scrollView else { return }
|
||||
scrollViewAdapter.scrollView = scrollView
|
||||
}
|
||||
.disabled(context.viewState.roomListMode == .skeletons)
|
||||
.animation(.elementDefault, value: context.viewState.showSessionVerificationBanner)
|
||||
.animation(.elementDefault, value: context.viewState.roomListMode)
|
||||
@@ -63,6 +76,14 @@ struct HomeScreen: View {
|
||||
userMenuButton
|
||||
}
|
||||
}
|
||||
.onReceive(scrollViewAdapter.isScrolling) { isScrolling in
|
||||
guard context.viewState.bindings.searchQuery.isEmpty,
|
||||
!isScrolling else {
|
||||
return
|
||||
}
|
||||
|
||||
context.send(viewAction: .updatedVisibleItemIdentifiers(visibleItemIdentifiers))
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
|
||||
Reference in New Issue
Block a user