mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-04 01:20:12 +00:00
Revert timeline item scrolling change in 3401d7a that seems to have introduced regressions.
This commit is contained in:
@@ -114,17 +114,17 @@ struct TimelineItemList: View {
|
|||||||
.onReceive(scrollToBottomPublisher) {
|
.onReceive(scrollToBottomPublisher) {
|
||||||
scrollToBottom(animated: true)
|
scrollToBottom(animated: true)
|
||||||
}
|
}
|
||||||
.onChange(of: context.viewState.items) { items in
|
.onChange(of: context.viewState.items.count) { _ in
|
||||||
defer {
|
guard !context.viewState.items.isEmpty,
|
||||||
// update the items anyway
|
context.viewState.items.count != timelineItems.count else {
|
||||||
timelineItems = items
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pin to the bottom if empty
|
// Pin to the bottom if empty
|
||||||
if timelineItems.isEmpty {
|
if timelineItems.isEmpty {
|
||||||
if let lastItem = items.last {
|
if let lastItem = context.viewState.items.last {
|
||||||
let pinnedItem = PinnedItem(id: lastItem.id, anchor: .bottom, animated: false)
|
let pinnedItem = PinnedItem(id: lastItem.id, anchor: .bottom, animated: false)
|
||||||
timelineItems = items
|
timelineItems = context.viewState.items
|
||||||
self.pinnedItem = pinnedItem
|
self.pinnedItem = pinnedItem
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,9 +134,9 @@ struct TimelineItemList: View {
|
|||||||
// Pin to the new bottom if visible
|
// Pin to the new bottom if visible
|
||||||
if let currentLastItem = timelineItems.last,
|
if let currentLastItem = timelineItems.last,
|
||||||
visibleItemIdentifiers.contains(currentLastItem.id),
|
visibleItemIdentifiers.contains(currentLastItem.id),
|
||||||
let newLastItem = items.last {
|
let newLastItem = context.viewState.items.last {
|
||||||
let pinnedItem = PinnedItem(id: newLastItem.id, anchor: .bottom, animated: false)
|
let pinnedItem = PinnedItem(id: newLastItem.id, anchor: .bottom, animated: false)
|
||||||
timelineItems = items
|
timelineItems = context.viewState.items
|
||||||
self.pinnedItem = pinnedItem
|
self.pinnedItem = pinnedItem
|
||||||
|
|
||||||
return
|
return
|
||||||
@@ -146,12 +146,20 @@ struct TimelineItemList: View {
|
|||||||
if let currentFirstItem = timelineItems.first,
|
if let currentFirstItem = timelineItems.first,
|
||||||
visibleItemIdentifiers.contains(currentFirstItem.id) {
|
visibleItemIdentifiers.contains(currentFirstItem.id) {
|
||||||
let pinnedItem = PinnedItem(id: currentFirstItem.id, anchor: .top, animated: false)
|
let pinnedItem = PinnedItem(id: currentFirstItem.id, anchor: .top, animated: false)
|
||||||
timelineItems = items
|
timelineItems = context.viewState.items
|
||||||
self.pinnedItem = pinnedItem
|
self.pinnedItem = pinnedItem
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise just update the items
|
||||||
|
timelineItems = context.viewState.items
|
||||||
}
|
}
|
||||||
|
.onChange(of: context.viewState.items, perform: { items in
|
||||||
|
if timelineItems != items {
|
||||||
|
timelineItems = items
|
||||||
|
}
|
||||||
|
})
|
||||||
.background(GeometryReader { geo in
|
.background(GeometryReader { geo in
|
||||||
Color.clear.preference(key: ViewFramePreferenceKey.self, value: [geo.frame(in: .global)])
|
Color.clear.preference(key: ViewFramePreferenceKey.self, value: [geo.frame(in: .global)])
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user