Implement artwork download and cache
This commit is contained in:
@@ -12,6 +12,7 @@ public struct OfflineLibraryTrack: Identifiable, Hashable, Sendable {
|
||||
public var localFilePath: String
|
||||
public var downloadedAt: Date?
|
||||
public var isFileAvailable: Bool
|
||||
public var localArtworkFilePath: String?
|
||||
|
||||
public init(
|
||||
remoteTrackId: String,
|
||||
@@ -22,7 +23,8 @@ public struct OfflineLibraryTrack: Identifiable, Hashable, Sendable {
|
||||
sha256: String,
|
||||
localFilePath: String,
|
||||
downloadedAt: Date?,
|
||||
isFileAvailable: Bool
|
||||
isFileAvailable: Bool,
|
||||
localArtworkFilePath: String? = nil
|
||||
) {
|
||||
self.remoteTrackId = remoteTrackId
|
||||
self.assetId = assetId
|
||||
@@ -33,6 +35,7 @@ public struct OfflineLibraryTrack: Identifiable, Hashable, Sendable {
|
||||
self.localFilePath = localFilePath
|
||||
self.downloadedAt = downloadedAt
|
||||
self.isFileAvailable = isFileAvailable
|
||||
self.localArtworkFilePath = localArtworkFilePath
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +56,7 @@ public struct OfflineLibraryRemoteTrack: Identifiable, Hashable, Sendable {
|
||||
public var isFileAvailable: Bool
|
||||
public var status: OfflineLibraryRemoteTrackStatus
|
||||
public var lastDownloadError: String?
|
||||
public var localArtworkFilePath: String?
|
||||
|
||||
public init(
|
||||
remoteTrack: RemoteTrack,
|
||||
@@ -60,7 +64,8 @@ public struct OfflineLibraryRemoteTrack: Identifiable, Hashable, Sendable {
|
||||
downloadedAt: Date?,
|
||||
isFileAvailable: Bool,
|
||||
status: OfflineLibraryRemoteTrackStatus,
|
||||
lastDownloadError: String?
|
||||
lastDownloadError: String?,
|
||||
localArtworkFilePath: String? = nil
|
||||
) {
|
||||
self.remoteTrack = remoteTrack
|
||||
self.localFilePath = localFilePath
|
||||
@@ -68,6 +73,7 @@ public struct OfflineLibraryRemoteTrack: Identifiable, Hashable, Sendable {
|
||||
self.isFileAvailable = isFileAvailable
|
||||
self.status = status
|
||||
self.lastDownloadError = lastDownloadError
|
||||
self.localArtworkFilePath = localArtworkFilePath
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,27 @@
|
||||
import Foundation
|
||||
|
||||
public struct RemoteArtwork: Codable, Hashable, Sendable {
|
||||
public var artworkId: String
|
||||
public var sha256: String
|
||||
public var mimeType: String
|
||||
public var width: Int?
|
||||
public var height: Int?
|
||||
|
||||
public init(
|
||||
artworkId: String,
|
||||
sha256: String,
|
||||
mimeType: String,
|
||||
width: Int? = nil,
|
||||
height: Int? = nil
|
||||
) {
|
||||
self.artworkId = artworkId
|
||||
self.sha256 = sha256
|
||||
self.mimeType = mimeType
|
||||
self.width = width
|
||||
self.height = height
|
||||
}
|
||||
}
|
||||
|
||||
public struct RemoteTrack: Identifiable, Codable, Hashable, Sendable {
|
||||
public var id: String { trackId }
|
||||
|
||||
@@ -11,6 +33,7 @@ public struct RemoteTrack: Identifiable, Codable, Hashable, Sendable {
|
||||
public var assetId: String
|
||||
public var createdAt: String
|
||||
public var updatedAt: String
|
||||
public var artwork: RemoteArtwork?
|
||||
|
||||
public init(
|
||||
trackId: String,
|
||||
@@ -20,7 +43,8 @@ public struct RemoteTrack: Identifiable, Codable, Hashable, Sendable {
|
||||
sha256: String,
|
||||
assetId: String,
|
||||
createdAt: String,
|
||||
updatedAt: String
|
||||
updatedAt: String,
|
||||
artwork: RemoteArtwork? = nil
|
||||
) {
|
||||
self.trackId = trackId
|
||||
self.title = title
|
||||
@@ -30,5 +54,6 @@ public struct RemoteTrack: Identifiable, Codable, Hashable, Sendable {
|
||||
self.assetId = assetId
|
||||
self.createdAt = createdAt
|
||||
self.updatedAt = updatedAt
|
||||
self.artwork = artwork
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user