50 lines
1.6 KiB
Swift
50 lines
1.6 KiB
Swift
// The full Recent list, opened from the feed's "N more" row. It loads `GET /v1/recent` when it
|
|
// appears; nothing polls. Rows look and swipe like the feed's, to settle or snooze, and the header
|
|
// has Settle all.
|
|
|
|
import SwiftUI
|
|
|
|
struct RecentView: View {
|
|
@Environment(AppModel.self) private var model
|
|
/// Snapshots render the rows without their List, which ImageRenderer leaves blank.
|
|
var scrolls = true
|
|
|
|
var body: some View {
|
|
Group {
|
|
if scrolls {
|
|
List { rows }
|
|
.listStyle(.plain)
|
|
.refreshable { await model.loadAllRecent() }
|
|
.task { await model.loadAllRecent() }
|
|
} else {
|
|
VStack(spacing: 6) { rows }
|
|
.padding(.horizontal, 4)
|
|
}
|
|
}
|
|
.navigationTitle("Recent")
|
|
}
|
|
|
|
@ViewBuilder private var rows: some View {
|
|
if let all = model.allRecent {
|
|
let items = model.visibleRecent(all)
|
|
RecentHeader(title: items.count == 1 ? "1 thread" : "\(items.count) threads", recent: items)
|
|
.feedRow()
|
|
ForEach(items) { item in
|
|
RecentRow(item: item).feedRow()
|
|
}
|
|
}
|
|
if model.allRecent == nil || model.allRecentError != nil {
|
|
LoadStatus(loaded: model.allRecent != nil, error: model.allRecentError, retry: model.loadAllRecent)
|
|
.feedRow()
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview("Recent") {
|
|
NavigationStack {
|
|
RecentView()
|
|
}
|
|
.environment(AppModel.preview())
|
|
.fontDesign(.rounded)
|
|
}
|