mirror of
https://github.com/yattee/yattee.git
synced 2025-10-11 09:58:14 +00:00
Less obnoxious error handling
This commit is contained in:
@@ -9,6 +9,7 @@ final class PlaylistsModel: ObservableObject {
|
||||
@Published var isLoading = false
|
||||
@Published var playlists = [Playlist]()
|
||||
@Published var reloadPlaylists = false
|
||||
@Published var error: RequestError?
|
||||
|
||||
var accounts = AccountsModel.shared
|
||||
|
||||
@@ -60,16 +61,14 @@ final class PlaylistsModel: ObservableObject {
|
||||
self?.isLoading = false
|
||||
}
|
||||
.onSuccess { resource in
|
||||
self.error = nil
|
||||
if let playlists: [Playlist] = resource.typedContent() {
|
||||
self.playlists = playlists
|
||||
PlaylistsCacheModel.shared.storePlaylist(account: account, playlists: playlists)
|
||||
onSuccess()
|
||||
}
|
||||
}
|
||||
.onFailure { error in
|
||||
self.playlists = []
|
||||
NavigationModel.shared.presentAlert(title: "Could not refresh Playlists", message: error.userMessage)
|
||||
}
|
||||
.onFailure { self.error = $0 }
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user