Merge pull request #1771 from Wevah/ios-candidate

Set lastImageCacheFlushDate on launch in CacheCleaner instead of registerDefaults()
This commit is contained in:
Maurice Parker 2020-02-03 10:09:26 -08:00 committed by GitHub
commit a5e1022bab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 6 deletions

View File

@ -226,8 +226,7 @@ struct AppDefaults {
let showDebugMenu = false let showDebugMenu = false
#endif #endif
let defaults: [String : Any] = [Key.lastImageCacheFlushDate: Date(), let defaults: [String : Any] = [Key.sidebarFontSize: FontSize.medium.rawValue,
Key.sidebarFontSize: FontSize.medium.rawValue,
Key.timelineFontSize: FontSize.medium.rawValue, Key.timelineFontSize: FontSize.medium.rawValue,
Key.detailFontSize: FontSize.medium.rawValue, Key.detailFontSize: FontSize.medium.rawValue,
Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue, Key.timelineSortDirection: ComparisonResult.orderedDescending.rawValue,

View File

@ -14,9 +14,14 @@ struct CacheCleaner {
static let log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "CacheCleaner") static let log = OSLog(subsystem: Bundle.main.bundleIdentifier!, category: "CacheCleaner")
static func purgeIfNecessary() { static func purgeIfNecessary() {
guard let flushDate = AppDefaults.lastImageCacheFlushDate else {
AppDefaults.lastImageCacheFlushDate = Date()
return
}
// If the image disk cache hasn't been flushed for 3 days and the network is available, delete it // If the image disk cache hasn't been flushed for 3 days and the network is available, delete it
if let flushDate = AppDefaults.lastImageCacheFlushDate, flushDate.addingTimeInterval(3600*24*3) < Date() { if flushDate.addingTimeInterval(3600 * 24 * 3) < Date() {
if let reachability = try? Reachability(hostname: "apple.com") { if let reachability = try? Reachability(hostname: "apple.com") {
if reachability.connection != .unavailable { if reachability.connection != .unavailable {

View File

@ -40,7 +40,7 @@ struct FaviconURLFinder {
/// - homePageURL: The page to search. /// - homePageURL: The page to search.
/// - completion: A closure called when the links have been found. /// - completion: A closure called when the links have been found.
/// - urls: An array of favicon URLs as strings. /// - urls: An array of favicon URLs as strings.
static func findFaviconURLs(with homePageURL: String, _ completion: @escaping (_ urls:[String]?) -> Void) { static func findFaviconURLs(with homePageURL: String, _ completion: @escaping (_ urls: [String]?) -> Void) {
guard let _ = URL(string: homePageURL) else { guard let _ = URL(string: homePageURL) else {
completion(nil) completion(nil)

View File

@ -150,8 +150,7 @@ struct AppDefaults {
} }
static func registerDefaults() { static func registerDefaults() {
let defaults: [String : Any] = [Key.lastImageCacheFlushDate: Date(), let defaults: [String : Any] = [Key.timelineGroupByFeed: false,
Key.timelineGroupByFeed: false,
Key.refreshClearsReadArticles: false, Key.refreshClearsReadArticles: false,
Key.timelineNumberOfLines: 2, Key.timelineNumberOfLines: 2,
Key.timelineIconSize: IconSize.medium.rawValue, Key.timelineIconSize: IconSize.medium.rawValue,