mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Prevent unnecessary backpagination requests from running every time a room is entered
- related to #1760 which moved initial timeline item computations to a serial queue
This commit is contained in:
committed by
Stefan Ceriu
parent
7aa81f542c
commit
31ca8ed7f2
@@ -215,7 +215,7 @@ struct RoomMemberState {
|
|||||||
/// Is also nice to have this as a wrapper for any state that is directly connected to the timeline.
|
/// Is also nice to have this as a wrapper for any state that is directly connected to the timeline.
|
||||||
struct TimelineViewState {
|
struct TimelineViewState {
|
||||||
var canBackPaginate = true
|
var canBackPaginate = true
|
||||||
var isBackPaginating = false
|
var isBackPaginating = true
|
||||||
|
|
||||||
// These can be removed when we have full swiftUI and moved as @State values in the view
|
// These can be removed when we have full swiftUI and moved as @State values in the view
|
||||||
var scrollToBottomPublisher = PassthroughSubject<Void, Never>()
|
var scrollToBottomPublisher = PassthroughSubject<Void, Never>()
|
||||||
|
|||||||
@@ -46,10 +46,6 @@ struct UITimelineView: UIViewControllerRepresentable {
|
|||||||
|
|
||||||
init(viewModelContext: RoomScreenViewModel.Context) {
|
init(viewModelContext: RoomScreenViewModel.Context) {
|
||||||
context = viewModelContext
|
context = viewModelContext
|
||||||
|
|
||||||
if viewModelContext.viewState.timelineViewState.itemViewStates.isEmpty {
|
|
||||||
viewModelContext.send(viewAction: .paginateBackwards)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Updates the specified table view's properties from the current view state.
|
/// Updates the specified table view's properties from the current view state.
|
||||||
|
|||||||
@@ -57,8 +57,11 @@ class RoomTimelineController: RoomTimelineControllerProtocol {
|
|||||||
}
|
}
|
||||||
.store(in: &cancellables)
|
.store(in: &cancellables)
|
||||||
|
|
||||||
|
// Inform the world that the initial items are loading from the store
|
||||||
|
callbacks.send(.isBackPaginating(true))
|
||||||
serialDispatchQueue.async {
|
serialDispatchQueue.async {
|
||||||
self.updateTimelineItems()
|
self.updateTimelineItems()
|
||||||
|
self.callbacks.send(.isBackPaginating(false))
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil)
|
NotificationCenter.default.addObserver(self, selector: #selector(contentSizeCategoryDidChange), name: UIContentSizeCategory.didChangeNotification, object: nil)
|
||||||
|
|||||||
Reference in New Issue
Block a user