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

[PP-1364] Update image loader to avoid race condition #447

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ac385ec
Resolve TOC navigation errors
mauricecarrier7 Jun 26, 2024
36ca31d
Merge branch 'beta' into PP-1406/TOC-navigation-error
mauricecarrier7 Jun 26, 2024
b0f5904
integrate updated audiobook toolkit
mauricecarrier7 Jul 1, 2024
3cc2ee8
Update project.pbxproj
mauricecarrier7 Jul 1, 2024
64825fa
Merge branch 'beta' into fix/PP-1412-Properly-map-feedbook-audiobook-…
mauricecarrier7 Jul 1, 2024
6ebd4a9
Update project.pbxproj
mauricecarrier7 Jul 1, 2024
d2a7a59
Update project.pbxproj
mauricecarrier7 Jul 1, 2024
0ad395f
Update TPPBookCellDelegate+Extensions.swift
mauricecarrier7 Jul 1, 2024
58c1879
Update ios-audiobooktoolkit
mauricecarrier7 Jul 1, 2024
bb790d9
Prevent LCP lock on startup
mauricecarrier7 Jul 3, 2024
0cdd63a
Merge branch 'beta' into task/PP-1373-LCP-audiobooks-freeze-on-startup
mauricecarrier7 Jul 3, 2024
23253d7
Update project.pbxproj
mauricecarrier7 Jul 3, 2024
3cd00bd
Resolve token refresh issue
mauricecarrier7 Jul 9, 2024
2bc7349
add pretty printing extension for debugging
mauricecarrier7 Jul 9, 2024
58f95c1
Update ios-audiobooktoolkit
mauricecarrier7 Jul 9, 2024
423efb2
Update project.pbxproj
mauricecarrier7 Jul 9, 2024
6c59b23
Merge branch 'beta' into task/PP-1408-show-correct-title-for-chapters
mauricecarrier7 Jul 9, 2024
ba96dab
Update project.pbxproj
mauricecarrier7 Jul 9, 2024
fe5e5c6
Update project.pbxproj
mauricecarrier7 Jul 9, 2024
3f38a11
Update ios-audiobooktoolkit
mauricecarrier7 Jul 9, 2024
f0ac922
Update ios-audiobooktoolkit
mauricecarrier7 Jul 10, 2024
91a6324
Multiple fixes
mauricecarrier7 Jul 12, 2024
8696556
Merge branch 'beta' into task/PP-1422-properly-display-local-annotations
mauricecarrier7 Jul 12, 2024
257bd90
merge in dev
mauricecarrier7 Jul 12, 2024
34c3639
Update project.pbxproj
mauricecarrier7 Jul 12, 2024
6e8b84b
Clean up
mauricecarrier7 Jul 12, 2024
6346001
Ensure image update is not missed by callback
mauricecarrier7 Jul 15, 2024
7a7962a
Merge branch 'beta' into fix/PP-1364/Update-image-loader-to-avoid-rac…
mauricecarrier7 Jul 15, 2024
f2a8392
Update project.pbxproj
mauricecarrier7 Jul 15, 2024
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
12 changes: 6 additions & 6 deletions Palace.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -5655,7 +5655,7 @@
CODE_SIGN_IDENTITY = "Apple Distribution";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 271;
CURRENT_PROJECT_VERSION = 272;
DEVELOPMENT_TEAM = 88CBA74T8K;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -5714,7 +5714,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Palace/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 271;
CURRENT_PROJECT_VERSION = 272;
DEVELOPMENT_TEAM = 88CBA74T8K;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -5899,7 +5899,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 271;
CURRENT_PROJECT_VERSION = 272;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -5960,7 +5960,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Palace/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 271;
CURRENT_PROJECT_VERSION = 272;
DEVELOPMENT_TEAM = 88CBA74T8K;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -6022,7 +6022,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 271;
CURRENT_PROJECT_VERSION = 272;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -6083,7 +6083,7 @@
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES_ERROR;
CODE_SIGN_ENTITLEMENTS = Palace/SimplyE.entitlements;
CODE_SIGN_IDENTITY = "iPhone Distribution";
CURRENT_PROJECT_VERSION = 271;
CURRENT_PROJECT_VERSION = 272;
DEVELOPMENT_TEAM = 88CBA74T8K;
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = 88CBA74T8K;
ENABLE_BITCODE = NO;
Expand Down
19 changes: 10 additions & 9 deletions Palace/Book/Models/TPPBookCoverRegistry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,14 @@ class TPPBookCoverRegistry {
/// - books: A set of `TPPBook` objects.
/// - handler: completion handler. `handler()` is called once, after all covers are downloaded.
func thumbnailImagesForBooks(_ books: Set<TPPBook>, handler: @escaping (_ bookIdentifiersToImages: [String: UIImage]) -> Void) {
var result: [String: UIImage] = [:] {
didSet {
if books.count == result.keys.count {
DispatchQueue.main.async {
handler(result)
}
}
}
}
var result: [String: UIImage] = [:]
let dispatchGroup = DispatchGroup()

books.forEach { book in
dispatchGroup.enter()
guard let thumbnailUrl = book.imageThumbnailURL else {
result[book.identifier] = self.generateBookCoverImage(book)
dispatchGroup.leave()
return
}

Expand All @@ -91,8 +87,13 @@ class TPPBookCoverRegistry {
result[book.identifier] = self.generateBookCoverImage(book)
}
}
dispatchGroup.leave()
}.resume()
}

dispatchGroup.notify(queue: .main) {
handler(result)
}
}

/// Immediately returns the cached thumbnail if available, else nil. Generated images are not returned.
Expand Down
2 changes: 1 addition & 1 deletion Palace/Book/UI/TPPBookDetailTableView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ private let standardCellHeight: CGFloat = 44.0
}

addPendingIndicator()
TPPOPDSFeed.withURL(url, shouldResetCache: false, useTokenIfAvailable: true) { (feed, errorDict) in
TPPOPDSFeed.withURL(url, shouldResetCache: false, useTokenIfAvailable: TPPUserAccount.sharedAccount().hasAdobeToken()) { (feed, errorDict) in
DispatchQueue.main.async {
if feed?.type == .acquisitionGrouped {
let groupedFeed = TPPCatalogGroupedFeed.init(opdsFeed: feed)
Expand Down
Loading