mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +00:00
Accounts loading improvements
This commit is contained in:
parent
a32f417776
commit
78940a005b
@ -143,6 +143,8 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
||||
updateToken()
|
||||
} else {
|
||||
FeedModel.shared.onAccountChange()
|
||||
SubscribedChannelsModel.shared.onAccountChange()
|
||||
PlaylistsModel.shared.onAccountChange()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,9 @@ final class PipedAPI: Service, ObservableObject, VideosAPI {
|
||||
if account.token.isNil || account.token!.isEmpty {
|
||||
updateToken()
|
||||
} else {
|
||||
FeedModel.shared.loadResources(force: true)
|
||||
FeedModel.shared.onAccountChange()
|
||||
SubscribedChannelsModel.shared.onAccountChange()
|
||||
PlaylistsModel.shared.onAccountChange()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -161,4 +161,9 @@ final class SubscribedChannelsModel: ObservableObject, CacheModel {
|
||||
var formattedCacheTime: String {
|
||||
getFormattedDate(channelsTime)
|
||||
}
|
||||
|
||||
func onAccountChange() {
|
||||
channels = []
|
||||
load(force: true)
|
||||
}
|
||||
}
|
||||
|
@ -108,6 +108,7 @@ final class FeedModel: ObservableObject, CacheModel {
|
||||
|
||||
func onAccountChange() {
|
||||
reset()
|
||||
error = nil
|
||||
loadResources(force: true)
|
||||
calculateUnwatchedFeed()
|
||||
}
|
||||
|
@ -123,4 +123,10 @@ final class PlaylistsModel: ObservableObject {
|
||||
private var resource: Resource? {
|
||||
accounts.api.playlists
|
||||
}
|
||||
|
||||
func onAccountChange() {
|
||||
error = nil
|
||||
playlists = []
|
||||
load()
|
||||
}
|
||||
}
|
||||
|
@ -38,16 +38,6 @@ struct ContentView: View {
|
||||
TVNavigationView()
|
||||
#endif
|
||||
}
|
||||
.onChange(of: accounts.current) { _ in
|
||||
subscriptions.load(force: true)
|
||||
playlists.load(force: true)
|
||||
}
|
||||
.onChange(of: accounts.signedIn) { newValue in
|
||||
guard newValue else { return }
|
||||
subscriptions.load(force: true)
|
||||
playlists.load(force: true)
|
||||
}
|
||||
|
||||
#if os(iOS)
|
||||
.overlay(videoPlayer)
|
||||
.sheet(isPresented: $navigation.presentingShareSheet) {
|
||||
|
Loading…
Reference in New Issue
Block a user