2021-09-25 13:48:22 +05:30
|
|
|
import Defaults
|
2021-09-19 02:06:42 +05:30
|
|
|
import Siesta
|
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct WatchNowSection: View {
|
|
|
|
let resource: Resource
|
|
|
|
let label: String
|
|
|
|
|
2021-09-25 13:48:22 +05:30
|
|
|
@StateObject private var store = Store<[Video]>()
|
|
|
|
|
2021-10-17 04:18:58 +05:30
|
|
|
@EnvironmentObject<AccountsModel> private var accounts
|
2021-09-25 13:48:22 +05:30
|
|
|
|
2021-09-19 02:06:42 +05:30
|
|
|
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 13:48:22 +05:30
|
|
|
resource.addObserver(store)
|
2021-09-28 23:36:05 +05:30
|
|
|
resource.loadIfNeeded()
|
2021-09-25 13:48:22 +05:30
|
|
|
}
|
2021-10-17 04:18:58 +05:30
|
|
|
.onChange(of: accounts.account) { _ in
|
2021-09-25 13:48:22 +05:30
|
|
|
resource.load()
|
2021-09-19 02:06:42 +05:30
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|