Timeline: Enable jump to latest + in place refresh for all other timeline types
This commit is contained in:
parent
43cb5164d1
commit
151154b335
|
@ -26,7 +26,6 @@ struct IceCubesApp: App {
|
|||
@StateObject private var sidebarRouterPath = RouterPath()
|
||||
|
||||
@State private var selectedTab: Tab = .timeline
|
||||
@State private var selectSidebarItem: Tab? = .timeline
|
||||
@State private var popToRootTab: Tab = .other
|
||||
@State private var sideBarLoadedTabs: Set<Tab> = Set()
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ struct TimelineTab: View {
|
|||
|
||||
@ViewBuilder
|
||||
private var timelineFilterButton: some View {
|
||||
if timeline == .home {
|
||||
if timeline.supportNewestPagination {
|
||||
Button {
|
||||
self.timeline = .latest
|
||||
} label: {
|
||||
|
|
|
@ -103,7 +103,11 @@ public struct TimelineView: View {
|
|||
.navigationBarTitleDisplayMode(.inline)
|
||||
.onAppear {
|
||||
viewModel.isTimelineVisible = true
|
||||
viewModel.client = client
|
||||
|
||||
if viewModel.client == nil {
|
||||
viewModel.client = client
|
||||
}
|
||||
|
||||
viewModel.timeline = timeline
|
||||
}
|
||||
.onDisappear {
|
||||
|
|
|
@ -12,9 +12,9 @@ class TimelineViewModel: ObservableObject {
|
|||
didSet {
|
||||
timelineTask?.cancel()
|
||||
timelineTask = Task {
|
||||
if timeline == .latest, let client {
|
||||
await cache.clearCache(for: client.id)
|
||||
timeline = .home
|
||||
if timeline == .latest {
|
||||
await clearHomeCache()
|
||||
timeline = oldValue
|
||||
}
|
||||
if oldValue != timeline {
|
||||
await datasource.reset()
|
||||
|
@ -68,7 +68,7 @@ class TimelineViewModel: ObservableObject {
|
|||
}
|
||||
|
||||
var pendingStatusesEnabled: Bool {
|
||||
timeline == .home
|
||||
timeline.supportNewestPagination
|
||||
}
|
||||
|
||||
var serverName: String {
|
||||
|
@ -100,6 +100,7 @@ class TimelineViewModel: ObservableObject {
|
|||
func handleEvent(event: any StreamEvent, currentAccount _: CurrentAccount) {
|
||||
Task {
|
||||
if let event = event as? StreamEventUpdate,
|
||||
timeline == .home,
|
||||
canStreamEvents,
|
||||
isTimelineVisible,
|
||||
pendingStatusesEnabled,
|
||||
|
@ -151,6 +152,12 @@ extension TimelineViewModel {
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
private func clearHomeCache() async {
|
||||
if let client, timeline == .home {
|
||||
await cache.clearCache(for: client.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - StatusesFetcher
|
||||
|
|
Loading…
Reference in New Issue