mirror of
https://github.com/yattee/yattee.git
synced 2025-10-09 00:48:10 +00:00
Use CachedAsyncImage if possible
This commit is contained in:
@@ -10,6 +10,8 @@ struct BaseCacheModel {
|
||||
static let jsonFromDataTransformer: (Data) -> JSON = { try! JSON(data: $0) }
|
||||
static let jsonTransformer = Transformer(toData: jsonToDataTransformer, fromData: jsonFromDataTransformer)
|
||||
|
||||
static let imageCache = URLCache(memoryCapacity: 512 * 1000 * 1000, diskCapacity: 10 * 1000 * 1000 * 1000)
|
||||
|
||||
var models: [CacheModel] {
|
||||
[
|
||||
FeedCacheModel.shared,
|
||||
@@ -23,10 +25,12 @@ struct BaseCacheModel {
|
||||
|
||||
func clear() {
|
||||
models.forEach { $0.clear() }
|
||||
|
||||
Self.imageCache.removeAllCachedResponses()
|
||||
}
|
||||
|
||||
var totalSize: Int {
|
||||
models.compactMap { $0.storage?.totalDiskStorageSize }.reduce(0, +)
|
||||
models.compactMap { $0.storage?.totalDiskStorageSize }.reduce(0, +) + Self.imageCache.currentDiskUsage
|
||||
}
|
||||
|
||||
var totalSizeFormatted: String {
|
||||
|
Reference in New Issue
Block a user