mirror of
https://github.com/yattee/yattee.git
synced 2026-10-23 13:12:53 +00:00
Filter the discarded feed timestamps on their own keys
The two dictionaries are not guaranteed to agree, and walking only the video keys left a timestamp behind for any feed entry that had already lost its videos. Nothing reads it — validity requires the videos too — but it names a feed this login was never shown.
This commit is contained in:
@@ -97,12 +97,15 @@ final class HomeInstanceCache {
|
||||
// popular and trending, which are public and cost a cold start
|
||||
// to fetch again. Anything the new login has already cached
|
||||
// wins over what came off disk.
|
||||
let isFeedKey = { (key: String) in
|
||||
key.hasSuffix("_\(InstanceContentType.feed.rawValue)")
|
||||
}
|
||||
var videos = cacheData.videos
|
||||
var timestamps = cacheData.lastUpdated
|
||||
for key in videos.keys where key.hasSuffix("_\(InstanceContentType.feed.rawValue)") {
|
||||
videos.removeValue(forKey: key)
|
||||
timestamps.removeValue(forKey: key)
|
||||
}
|
||||
// Filtered independently: a timestamp can outlive its entry,
|
||||
// and one left behind is a feed this login was never shown.
|
||||
videos = videos.filter { !isFeedKey($0.key) }
|
||||
timestamps = timestamps.filter { !isFeedKey($0.key) }
|
||||
videos.merge(cache) { _, current in current }
|
||||
timestamps.merge(lastUpdated) { _, current in current }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user