mirror of
https://github.com/yattee/yattee.git
synced 2026-10-23 05:02:53 +00:00
Show player toasts and drop the unused instance status
PlayerService's toast manager was never set, so stream refresh, missing download and skip-to-next toasts were silently dropped. Wire it up in AppEnvironment. InstancesManager's per-instance status was never written since the v2 rewrite; account statuses already cover rejected and missing credentials in the sources list, so remove it along with its unreachable row branch.
This commit is contained in:
@@ -451,6 +451,7 @@ final class AppEnvironment {
|
||||
self.toastManager = toast
|
||||
toast.setNavigationCoordinator(self.navigationCoordinator)
|
||||
remoteControl.setToastManager(toast)
|
||||
player.setToastManager(toast)
|
||||
self.downloadManager.setToastManager(toast)
|
||||
self.downloadManager.setDownloadSettings(self.downloadSettings)
|
||||
|
||||
|
||||
@@ -8,16 +8,6 @@
|
||||
import Foundation
|
||||
import SwiftUI
|
||||
|
||||
/// Status of an instance's connectivity and authentication.
|
||||
enum InstanceStatus: Equatable {
|
||||
/// Instance is online and working.
|
||||
case online
|
||||
/// Instance requires authentication but credentials are not provided.
|
||||
case authRequired
|
||||
/// Instance authentication failed (wrong credentials).
|
||||
case authFailed
|
||||
}
|
||||
|
||||
/// Manages the list of configured backend instances with iCloud sync.
|
||||
@MainActor
|
||||
@Observable
|
||||
@@ -38,9 +28,6 @@ final class InstancesManager {
|
||||
private(set) var instances: [Instance] = []
|
||||
private(set) var activeInstanceID: UUID?
|
||||
|
||||
/// Current status of each instance, keyed by instance ID.
|
||||
private(set) var instanceStatuses: [UUID: InstanceStatus] = [:]
|
||||
|
||||
// MARK: - Initialization
|
||||
|
||||
/// - Parameter defaults: where the configured instances are read and
|
||||
@@ -319,13 +306,6 @@ final class InstancesManager {
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: - Instance Status
|
||||
|
||||
/// Returns the current status of an instance.
|
||||
func status(for instance: Instance) -> InstanceStatus {
|
||||
instanceStatuses[instance.id] ?? .online
|
||||
}
|
||||
|
||||
/// The currently active instance for browsing content.
|
||||
/// Falls back to the first enabled instance if no active instance is set.
|
||||
var activeInstance: Instance? {
|
||||
|
||||
@@ -415,11 +415,8 @@ struct SourcesListView: View {
|
||||
appEnvironment?.needsCredentials(for: instance) ?? false
|
||||
}
|
||||
|
||||
/// Whether one of this source's logins is being refused by the server.
|
||||
///
|
||||
/// The instance-level statuses below know nothing about accounts, so a
|
||||
/// rejected login would otherwise show up nowhere the user looks for their
|
||||
/// sources.
|
||||
/// Whether one of this source's logins is being refused by the server, so a
|
||||
/// rejected login shows up where the user looks for their sources.
|
||||
private func hasRejectedAccount(_ instance: Instance) -> Bool {
|
||||
guard let accountsManager = appEnvironment?.accountsManager else { return false }
|
||||
|
||||
@@ -443,19 +440,6 @@ struct SourcesListView: View {
|
||||
Label(String(localized: "sources.status.authRequired"), systemImage: "key.fill")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.orange)
|
||||
} else if let status = instancesManager?.status(for: instance) {
|
||||
switch status {
|
||||
case .authFailed:
|
||||
Label(String(localized: "sources.status.authFailed"), systemImage: "exclamationmark.triangle.fill")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.orange)
|
||||
case .authRequired:
|
||||
Label(String(localized: "sources.status.authRequired"), systemImage: "key.fill")
|
||||
.font(.caption2)
|
||||
.foregroundStyle(.orange)
|
||||
default:
|
||||
EmptyView()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user