mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
Timeline: Dequeue one
This commit is contained in:
parent
511717e492
commit
88b56fe016
2 changed files with 32 additions and 9 deletions
|
@ -109,6 +109,7 @@ public struct TimelineView: View {
|
|||
@ViewBuilder
|
||||
private func makePendingNewPostsView(proxy: ScrollViewProxy) -> some View {
|
||||
if !viewModel.pendingStatuses.isEmpty {
|
||||
HStack(spacing: 6) {
|
||||
Button {
|
||||
withAnimation {
|
||||
proxy.scrollTo(Constants.scrollToTop)
|
||||
|
@ -120,6 +121,19 @@ public struct TimelineView: View {
|
|||
.buttonStyle(.bordered)
|
||||
.background(.thinMaterial)
|
||||
.cornerRadius(8)
|
||||
if viewModel.pendingStatuses.count > 1 {
|
||||
Button {
|
||||
withAnimation {
|
||||
viewModel.dequeuePendingStatuses()
|
||||
}
|
||||
} label: {
|
||||
Image(systemName: "play.square.stack")
|
||||
}
|
||||
.buttonStyle(.bordered)
|
||||
.background(.thinMaterial)
|
||||
.cornerRadius(8)
|
||||
}
|
||||
}
|
||||
.padding(.top, 6)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -179,4 +179,13 @@ class TimelineViewModel: ObservableObject, StatusesFetcher {
|
|||
pendingStatuses = []
|
||||
statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
|
||||
}
|
||||
|
||||
func dequeuePendingStatuses() {
|
||||
guard timeline == .home else { return }
|
||||
if pendingStatuses.count > 1 {
|
||||
let status = pendingStatuses.removeLast()
|
||||
statuses.insert(status, at: 0)
|
||||
}
|
||||
statusesState = .display(statuses: statuses, nextPageState: .hasNextPage)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue