Skip to content

Commit e3f4fc2

Browse files
committed
both using .default to have the same cache
1 parent ced5270 commit e3f4fc2

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

BeeSwift/Components/GoalImageView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import OSLog
77
/// Shows the current graph for a goal
88
/// Handles placeholders for loading and queued states, and automatically updates when the goal changes
99
class GoalImageView: UIView {
10-
private static let downloader = ImageDownloader(imageCache: AutoPurgingImageCache())
10+
private static let downloader = ImageDownloadService.shared.downloader
1111
private let logger = Logger(subsystem: "com.beeminder.com", category: "GoalImageView")
1212

1313
private let imageView = UIImageView()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Part of BeeSwift. Copyright Beeminder
2+
3+
import AlamofireImage
4+
5+
final class ImageDownloadService {
6+
static let shared = ImageDownloadService()
7+
let downloader: ImageDownloader
8+
9+
private init() { downloader = ImageDownloader.default }
10+
}

BeeSwift/Gallery/GalleryViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,13 @@ extension GalleryViewController: UICollectionViewDelegate {
503503
}
504504
}
505505

506-
// MARK: - Prefetching (using AlamofireImage's ImageDownloader)
507506
extension GalleryViewController: UICollectionViewDataSourcePrefetching {
508507
func collectionView(_ collectionView: UICollectionView, prefetchItemsAt indexPaths: [IndexPath]) {
509508
let urls = indexPaths.compactMap { indexPath -> URL? in
510509
let goal = fetchedResultsController.object(at: indexPath)
511510
return try? goal.thumbUrl.asURL()
512511
}
513-
let downloader = ImageDownloader.default
512+
let downloader = ImageDownloadService.shared.downloader
514513
urls.forEach { downloader.download(URLRequest(url: $0), completion: { _ in }) }
515514
}
516515
}

0 commit comments

Comments
 (0)