mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Pull to refresh fixes, added alert for playlist error
This commit is contained in:
parent
14b0316724
commit
dffcfc8b06
@ -53,8 +53,9 @@ final class PlaylistsModel: ObservableObject {
|
|||||||
onSuccess()
|
onSuccess()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onFailure { _ in
|
.onFailure { error in
|
||||||
self.playlists = []
|
self.playlists = []
|
||||||
|
NavigationModel.shared.presentAlert(title: "Could not refresh Playlists", message: error.userMessage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +129,21 @@ struct PlaylistsView: View {
|
|||||||
.onChange(of: model.reloadPlaylists) { _ in
|
.onChange(of: model.reloadPlaylists) { _ in
|
||||||
resource?.load()
|
resource?.load()
|
||||||
}
|
}
|
||||||
|
#if os(iOS)
|
||||||
|
.refreshControl { refreshControl in
|
||||||
|
model.load(force: true) {
|
||||||
|
model.reloadPlaylists.toggle()
|
||||||
|
refreshControl.endRefreshing()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.backport
|
||||||
|
.refreshable {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
model.load(force: true) { model.reloadPlaylists.toggle() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.navigationBarTitleDisplayMode(RefreshControl.navigationBarTitleDisplayMode)
|
||||||
|
#endif
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
.fullScreenCover(isPresented: $showingNewPlaylist, onDismiss: selectCreatedPlaylist) {
|
.fullScreenCover(isPresented: $showingNewPlaylist, onDismiss: selectCreatedPlaylist) {
|
||||||
PlaylistFormView(playlist: $createdPlaylist)
|
PlaylistFormView(playlist: $createdPlaylist)
|
||||||
@ -155,15 +170,22 @@ struct PlaylistsView: View {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
#endif
|
#endif
|
||||||
#if os(iOS)
|
|
||||||
.navigationBarTitleDisplayMode(RefreshControl.navigationBarTitleDisplayMode)
|
|
||||||
#endif
|
|
||||||
#if !os(macOS)
|
#if !os(macOS)
|
||||||
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
|
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) { _ in
|
||||||
model.load()
|
model.load()
|
||||||
resource?.loadIfNeeded()
|
resource?.loadIfNeeded()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
#if !os(tvOS)
|
||||||
|
.background(
|
||||||
|
Button("Refresh") {
|
||||||
|
resource?.load()
|
||||||
|
}
|
||||||
|
.keyboardShortcut("r")
|
||||||
|
.opacity(0)
|
||||||
|
)
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if os(tvOS)
|
#if os(tvOS)
|
||||||
|
@ -140,8 +140,10 @@ struct TrendingView: View {
|
|||||||
}
|
}
|
||||||
.backport
|
.backport
|
||||||
.refreshable {
|
.refreshable {
|
||||||
resource.load().onFailure { error in
|
DispatchQueue.main.async {
|
||||||
NavigationModel.shared.presentAlert(title: "Could not refresh Trending", message: error.userMessage)
|
resource.load().onFailure { error in
|
||||||
|
NavigationModel.shared.presentAlert(title: "Could not refresh Trending", message: error.userMessage)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.navigationBarTitleDisplayMode(RefreshControl.navigationBarTitleDisplayMode)
|
.navigationBarTitleDisplayMode(RefreshControl.navigationBarTitleDisplayMode)
|
||||||
|
@ -50,7 +50,9 @@ struct PopularView: View {
|
|||||||
}
|
}
|
||||||
.backport
|
.backport
|
||||||
.refreshable {
|
.refreshable {
|
||||||
resource?.load()
|
DispatchQueue.main.async {
|
||||||
|
resource?.load()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.navigationBarTitleDisplayMode(RefreshControl.navigationBarTitleDisplayMode)
|
.navigationBarTitleDisplayMode(RefreshControl.navigationBarTitleDisplayMode)
|
||||||
#endif
|
#endif
|
||||||
|
@ -32,7 +32,7 @@ struct SubscriptionsView: View {
|
|||||||
}
|
}
|
||||||
.backport
|
.backport
|
||||||
.refreshable {
|
.refreshable {
|
||||||
loadResources(force: true)
|
await loadResources(force: true)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user