1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 06:10:32 +05:30
yattee/Shared/Views/SubscriptionsView.swift

31 lines
752 B
Swift
Raw Normal View History

2021-06-12 04:19:42 +05:30
import SwiftUI
struct SubscriptionsView: View {
2021-06-28 16:13:07 +05:30
@ObservedObject private var store = Store<[Video]>()
2021-06-26 17:07:24 +05:30
2021-08-26 03:42:59 +05:30
var resource = InvidiousAPI.shared.feed
2021-06-12 04:19:42 +05:30
2021-06-28 16:13:07 +05:30
init() {
resource.addObserver(store)
}
2021-06-26 17:07:24 +05:30
2021-06-28 16:13:07 +05:30
var body: some View {
VideosView(videos: store.collection)
.onAppear {
2021-09-19 23:01:21 +05:30
if let home = InvidiousAPI.shared.home.loadIfNeeded() {
home.onSuccess { _ in
resource.loadIfNeeded()
}
} else {
resource.loadIfNeeded()
}
2021-06-28 16:13:07 +05:30
}
2021-07-12 02:22:49 +05:30
.refreshable {
resource.load()
}
#if !os(tvOS)
.navigationTitle("Subscriptions")
#endif
2021-06-12 04:19:42 +05:30
}
}