2021-09-25 08:18:22 +00:00
|
|
|
import Defaults
|
2021-09-18 20:36:42 +00:00
|
|
|
import Siesta
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct WatchNowSection: View {
|
|
|
|
let resource: Resource
|
|
|
|
let label: String
|
|
|
|
|
2021-09-25 08:18:22 +00:00
|
|
|
@StateObject private var store = Store<[Video]>()
|
|
|
|
|
|
|
|
@EnvironmentObject<InvidiousAPI> private var api
|
|
|
|
|
2021-09-18 20:36:42 +00:00
|
|
|
init(resource: Resource, label: String) {
|
|
|
|
self.resource = resource
|
|
|
|
self.label = label
|
|
|
|
}
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
WatchNowSectionBody(label: label, videos: store.collection)
|
|
|
|
.onAppear {
|
2021-09-25 08:18:22 +00:00
|
|
|
resource.addObserver(store)
|
2021-09-28 18:06:05 +00:00
|
|
|
resource.loadIfNeeded()
|
2021-09-25 08:18:22 +00:00
|
|
|
}
|
|
|
|
.onChange(of: api.account) { _ in
|
|
|
|
resource.load()
|
2021-09-18 20:36:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|