mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Limit number of stored feed items
This commit is contained in:
parent
f6a261662c
commit
3c546f96df
@ -5,6 +5,7 @@ import SwiftyJSON
|
||||
|
||||
struct FeedCacheModel {
|
||||
static let shared = FeedCacheModel()
|
||||
static let limit = 30
|
||||
let logger = Logger(label: "stream.yattee.cache.feed")
|
||||
|
||||
static let diskConfig = DiskConfig(name: "feed")
|
||||
@ -20,7 +21,7 @@ struct FeedCacheModel {
|
||||
let date = iso8601DateFormatter.string(from: Date())
|
||||
logger.info("caching feed \(account.feedCacheKey) -- \(date)")
|
||||
let feedTimeObject: JSON = ["date": date]
|
||||
let videosObject: JSON = ["videos": videos.map(\.json).map(\.object)]
|
||||
let videosObject: JSON = ["videos": videos.prefix(Self.limit).map { $0.json.object }]
|
||||
try? storage.setObject(feedTimeObject, forKey: feedTimeCacheKey(account.feedCacheKey))
|
||||
try? storage.setObject(videosObject, forKey: account.feedCacheKey)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user