diff --git a/Model/Applications/InvidiousAPI.swift b/Model/Applications/InvidiousAPI.swift index 9a37f9e8..1931d95d 100644 --- a/Model/Applications/InvidiousAPI.swift +++ b/Model/Applications/InvidiousAPI.swift @@ -66,8 +66,12 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI { .onSuccess { _ in self.signedIn = true } - .onFailure { _ in + .onFailure { requestError in self.signedIn = false + NavigationModel.shared.presentAlert( + title: "Could not connect with your account", + message: "\(requestError.httpStatusCode ?? -1) - \(requestError.userMessage)\nIf this issue persists, try removing and adding your account again in Settings." + ) } } diff --git a/Model/Applications/PipedAPI.swift b/Model/Applications/PipedAPI.swift index 01162622..2ac47cc2 100644 --- a/Model/Applications/PipedAPI.swift +++ b/Model/Applications/PipedAPI.swift @@ -121,6 +121,13 @@ final class PipedAPI: Service, ObservableObject, VideosAPI { ) .onSuccess { response in self.account.token = response.json.dictionaryValue["token"]?.string ?? "" + if let error = response.json.dictionaryValue["error"]?.string { + NavigationModel.shared.presentAlert( + title: "Could not connect with your account", + message: error + ) + } + self.configure() } } diff --git a/Model/NavigationModel.swift b/Model/NavigationModel.swift index 06770bb3..b2d885bd 100644 --- a/Model/NavigationModel.swift +++ b/Model/NavigationModel.swift @@ -2,6 +2,8 @@ import Foundation import SwiftUI final class NavigationModel: ObservableObject { + static var shared: NavigationModel! + enum TabSelection: Hashable { case favorites case subscriptions diff --git a/Shared/YatteeApp.swift b/Shared/YatteeApp.swift index f53bc298..3284f269 100644 --- a/Shared/YatteeApp.swift +++ b/Shared/YatteeApp.swift @@ -226,6 +226,8 @@ struct YatteeApp: App { navigation.tabSelection = section ?? .search + NavigationModel.shared = navigation + subscriptions.load() playlists.load()