mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Various sliding sync tweaks (#446)
* Refactor SS configuration and add (unfinished) support for adding views dynamically. * Implement pop and clear support on the room summary provider * Register views against sliding sync * Read invalidated vislbeRoomsSummaryProvider from the allRoomSummaryProvider * Switch SS window range setting from the ScrollViewAdapter to a publisher debounce * Tweak allRoomsView addition: switch from listening the visibleRoomsView's state to when it publishes the first diff update * Cleanup client delegate and sliding sync observers and lifecycle * Bump the RustSDK to 1.0.30-alpha * Reuse startSync within restartSync
This commit is contained in:
@@ -17,12 +17,17 @@
|
||||
import SwiftUI
|
||||
|
||||
struct HomeScreen: View {
|
||||
@State private var showingLogoutConfirmation = false
|
||||
@State private var visibleItemIdentifiers = Set<String>()
|
||||
@State private var scrollViewAdapter = ScrollViewAdapter()
|
||||
|
||||
@ObservedObject var context: HomeScreenViewModel.Context
|
||||
|
||||
@State private var showingLogoutConfirmation = false
|
||||
@State private var visibleItemIdentifiers = Set<String>() {
|
||||
didSet {
|
||||
if visibleItemIdentifiers != oldValue {
|
||||
updateVisibleRange()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
ScrollView {
|
||||
if context.viewState.showSessionVerificationBanner {
|
||||
@@ -62,10 +67,6 @@ struct HomeScreen: View {
|
||||
.disableAutocorrection(true)
|
||||
}
|
||||
}
|
||||
.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)
|
||||
@@ -76,14 +77,6 @@ struct HomeScreen: View {
|
||||
userMenuButton
|
||||
}
|
||||
}
|
||||
.onReceive(scrollViewAdapter.isScrolling) { isScrolling in
|
||||
guard context.viewState.bindings.searchQuery.isEmpty,
|
||||
!isScrolling else {
|
||||
return
|
||||
}
|
||||
|
||||
context.send(viewAction: .updatedVisibleItemIdentifiers(visibleItemIdentifiers))
|
||||
}
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
@@ -191,6 +184,22 @@ struct HomeScreen: View {
|
||||
private func signOut() {
|
||||
context.send(viewAction: .userMenu(action: .signOut))
|
||||
}
|
||||
|
||||
private func updateVisibleRange() {
|
||||
let result = visibleItemIdentifiers.compactMap { itemIdentifier in
|
||||
context.viewState.rooms.firstIndex { $0.id == itemIdentifier }
|
||||
}.sorted()
|
||||
|
||||
guard !result.isEmpty else {
|
||||
return
|
||||
}
|
||||
|
||||
guard let firstIndex = result.first, let lastIndex = result.last else {
|
||||
return
|
||||
}
|
||||
|
||||
context.send(viewAction: .updatedVisibleItemRange(firstIndex..<lastIndex))
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Previews
|
||||
|
||||
Reference in New Issue
Block a user