mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Fix handling feed
This commit is contained in:
parent
2812ea0301
commit
b55c6f8619
@ -34,30 +34,7 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
||||
func setAccount(_ account: Account) {
|
||||
self.account = account
|
||||
|
||||
wipeResources()
|
||||
configure()
|
||||
|
||||
if !account.anonymous {
|
||||
validate()
|
||||
}
|
||||
}
|
||||
|
||||
func validate() {
|
||||
validateSID()
|
||||
}
|
||||
|
||||
func validateSID() {
|
||||
guard signedIn, !(account.token?.isEmpty ?? true) else {
|
||||
return
|
||||
}
|
||||
|
||||
feed?
|
||||
.load()
|
||||
.onFailure { _ in
|
||||
self.updateToken(force: true)
|
||||
}
|
||||
|
||||
wipeResources()
|
||||
}
|
||||
|
||||
func configure() {
|
||||
@ -162,7 +139,11 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
||||
return CommentsPage(comments: comments, nextPage: nextPage, disabled: disabled)
|
||||
}
|
||||
|
||||
updateToken()
|
||||
if account.token.isNil || account.token!.isEmpty {
|
||||
updateToken()
|
||||
} else {
|
||||
FeedModel.shared.onAccountChange()
|
||||
}
|
||||
}
|
||||
|
||||
func updateToken(force: Bool = false) {
|
||||
|
@ -26,7 +26,6 @@ final class PipedAPI: Service, ObservableObject, VideosAPI {
|
||||
func setAccount(_ account: Account) {
|
||||
self.account = account
|
||||
|
||||
wipeResources()
|
||||
configure()
|
||||
}
|
||||
|
||||
@ -108,8 +107,10 @@ final class PipedAPI: Service, ObservableObject, VideosAPI {
|
||||
content.json.arrayValue.compactMap { self.extractUserPlaylist(from: $0) }
|
||||
}
|
||||
|
||||
if account.token.isNil {
|
||||
if account.token.isNil || account.token!.isEmpty {
|
||||
updateToken()
|
||||
} else {
|
||||
FeedModel.shared.loadResources(force: true)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -106,6 +106,12 @@ final class FeedModel: ObservableObject, CacheModel {
|
||||
loadFeed(force: true, paginating: true)
|
||||
}
|
||||
|
||||
func onAccountChange() {
|
||||
reset()
|
||||
loadResources(force: true)
|
||||
calculateUnwatchedFeed()
|
||||
}
|
||||
|
||||
func calculateUnwatchedFeed() {
|
||||
guard let account = accounts.current, accounts.signedIn else { return }
|
||||
let feed = cacheModel.retrieveFeed(account: account)
|
||||
|
@ -22,10 +22,6 @@ struct FeedView: View {
|
||||
.onAppear {
|
||||
feed.loadResources()
|
||||
}
|
||||
.onChange(of: accounts.current) { _ in
|
||||
feed.reset()
|
||||
feed.loadResources(force: true)
|
||||
}
|
||||
#if os(iOS)
|
||||
.refreshControl { refreshControl in
|
||||
feed.loadResources(force: true) {
|
||||
|
Loading…
Reference in New Issue
Block a user