Yattee v2 rewrite

This commit is contained in:
Arkadiusz Fal
2026-02-08 18:31:16 +01:00
parent 20d0cfc0c7
commit 05f921d605
1043 changed files with 163875 additions and 68430 deletions

View File

@@ -0,0 +1,54 @@
//
// UnifiedSource.swift
// Yattee
//
// Unified wrapper for Instance and MediaSource types for display in the Sources settings.
//
import Foundation
/// Represents any source type for unified display in the Sources list.
enum UnifiedSource: Identifiable, Hashable, Sendable {
case remoteServer(Instance)
case fileSource(MediaSource)
// MARK: - Identifiable
var id: UUID {
switch self {
case .remoteServer(let instance):
return instance.id
case .fileSource(let source):
return source.id
}
}
// MARK: - Common Properties
var name: String {
switch self {
case .remoteServer(let instance):
return instance.displayName
case .fileSource(let source):
return source.name
}
}
var isEnabled: Bool {
switch self {
case .remoteServer(let instance):
return instance.isEnabled
case .fileSource(let source):
return source.isEnabled
}
}
var urlDisplayString: String {
switch self {
case .remoteServer(let instance):
return instance.url.host ?? instance.url.absoluteString
case .fileSource(let source):
return source.urlDisplayString
}
}
}