mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-23 00:40:59 +00:00
Various optimizations for the new timeline
This commit is contained in:
parent
83049517c0
commit
9bf40b262f
3 changed files with 5 additions and 5 deletions
|
@ -28,7 +28,7 @@ class PendingStatusesObserver: ObservableObject {
|
|||
|
||||
struct PendingStatusesObserverView: View {
|
||||
@ObservedObject var observer: PendingStatusesObserver
|
||||
@State var proxy: ScrollViewProxy
|
||||
var proxy: ScrollViewProxy
|
||||
|
||||
var body: some View {
|
||||
if observer.pendingStatusesCount > 0 {
|
||||
|
@ -36,7 +36,7 @@ struct PendingStatusesObserverView: View {
|
|||
Spacer()
|
||||
Button {
|
||||
withAnimation {
|
||||
proxy.scrollTo(observer.pendingStatuses.last, anchor: .bottom)
|
||||
proxy.scrollTo(observer.pendingStatuses.last, anchor: .top)
|
||||
}
|
||||
} label: {
|
||||
Text("\(observer.pendingStatusesCount)")
|
||||
|
|
|
@ -48,7 +48,7 @@ public struct TimelineView: View {
|
|||
StatusesListView(fetcher: viewModel)
|
||||
}
|
||||
}
|
||||
.id(account.account?.id)
|
||||
.id(account.account?.id ?? client.id)
|
||||
.environment(\.defaultMinListRowHeight, 1)
|
||||
.listStyle(.plain)
|
||||
.scrollContentBackground(.hidden)
|
||||
|
|
|
@ -70,7 +70,7 @@ class TimelineViewModel: ObservableObject, StatusesFetcher {
|
|||
}
|
||||
} else if let first = statuses.first {
|
||||
canStreamEvents = false
|
||||
var newStatuses: [Status] = await fetchNewPages(minId: first.id, maxPages: 20)
|
||||
var newStatuses: [Status] = await fetchNewPages(minId: first.id, maxPages: 10)
|
||||
if !pendingStatusesEnabled {
|
||||
statuses.insert(contentsOf: newStatuses, at: 0)
|
||||
pendingStatusesObserver.pendingStatuses = []
|
||||
|
@ -98,7 +98,7 @@ class TimelineViewModel: ObservableObject, StatusesFetcher {
|
|||
withAnimation {
|
||||
statusesState = .display(statuses: statuses, nextPageState: statuses.count < 20 ? .none : .hasNextPage)
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.01) {
|
||||
self.scrollProxy?.scrollTo(firstStatusId)
|
||||
self.scrollProxy?.scrollTo(firstStatusId, anchor: .top)
|
||||
self.pendingStatusesObserver.disableUpdate = false
|
||||
self.canStreamEvents = true
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue