Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use a better name #346

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions Sources/MissingArtwork/ArtworksModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,26 @@ extension Logger {
case image(PlatformImage)
}

var catalogImages: [MissingArtwork: ImageState] = [:]
var partialLibraryImages: [MissingArtwork: ImageState] = [:]

@MainActor
func load(image missingArtwork: MissingArtwork) async {
guard catalogImages[missingArtwork] == nil else {
Logger.artworksModel.log("Already loaded catalog image: \(missingArtwork, privacy: .public)")
guard partialLibraryImages[missingArtwork] == nil else {
Logger.artworksModel.log("Already loaded partial library image: \(missingArtwork, privacy: .public)")
return
}

Logger.artworksModel.log("Loading catalog image: \(missingArtwork, privacy: .public)")
catalogImages[missingArtwork] = .loading
Logger.artworksModel.log("Loading partial library image: \(missingArtwork, privacy: .public)")
partialLibraryImages[missingArtwork] = .loading
do {
catalogImages[missingArtwork] = .image(try await missingArtwork.matchingPartialArtworkImage())
Logger.artworksModel.log("Loaded catalog image: \(missingArtwork, privacy: .public)")
partialLibraryImages[missingArtwork] = .image(
try await missingArtwork.matchingPartialArtworkImage())
Logger.artworksModel.log("Loaded partial library image: \(missingArtwork, privacy: .public)")
} catch {
Logger.artworksModel.log(
"Error loading catalog image: \(missingArtwork, privacy: .public) \(error, privacy: .public)"
"Error loading partial library image: \(missingArtwork, privacy: .public) \(error, privacy: .public)"
)
catalogImages[missingArtwork] = .error(error)
partialLibraryImages[missingArtwork] = .error(error)
}
}
}
4 changes: 2 additions & 2 deletions Sources/MissingArtwork/PartialArtworkImageView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ struct PartialArtworkImageView: View {
"Partial Artwork Is Already Ready To Repair", bundle: .module,
comment: "Text shown when a partial artwork is selected."
).font(.headline)
if let catalogImage = model.catalogImages[missingArtwork] {
switch catalogImage {
if let partialLibraryImage = model.partialLibraryImages[missingArtwork] {
switch partialLibraryImage {
case .loading:
ProgressView()
case .error(_):
Expand Down