diff --git a/WMF Framework/SharedContainerCache.swift b/WMF Framework/SharedContainerCache.swift index f7001eeb2e2..94269699b83 100644 --- a/WMF Framework/SharedContainerCache.swift +++ b/WMF Framework/SharedContainerCache.swift @@ -3,6 +3,7 @@ import Foundation @objc public class SharedContainerCacheCommonNames: NSObject { @objc public static let pushNotificationsCache = "Push Notifications Cache" @objc public static let talkPageCache = "Talk Page Cache" + public static let widgetCache = "Widget Cache" } public final class SharedContainerCache: SharedContainerCacheHousekeepingProtocol { @@ -84,7 +85,7 @@ public final class SharedContainerCache: SharedContainerCacheHouseke @objc public class SharedContainerCacheClearFeaturedArticleWrapper: NSObject { @objc public static func clearOutFeaturedArticleWidgetCache() { - let sharedCache = SharedContainerCache(fileName: "Widget Cache", defaultCache: { WidgetCache(settings: .default, featuredContent: nil) }) + let sharedCache = SharedContainerCache(fileName: SharedContainerCacheCommonNames.widgetCache, defaultCache: { WidgetCache(settings: .default, featuredContent: nil) }) var updatedCache = sharedCache.loadCache() updatedCache.featuredContent = nil sharedCache.saveCache(updatedCache) diff --git a/WMF Framework/Widget/WidgetController.swift b/WMF Framework/Widget/WidgetController.swift index d86b6779837..f15537d3233 100644 --- a/WMF Framework/Widget/WidgetController.swift +++ b/WMF Framework/Widget/WidgetController.swift @@ -21,7 +21,7 @@ public final class WidgetController: NSObject { // MARK: Properties @objc public static let shared = WidgetController() - private let sharedCache = SharedContainerCache(fileName: "Widget Cache", defaultCache: { WidgetCache(settings: .default, featuredContent: nil) }) + private let sharedCache = SharedContainerCache(fileName: SharedContainerCacheCommonNames.widgetCache, defaultCache: { WidgetCache(settings: .default, featuredContent: nil) }) // MARK: Public diff --git a/Wikipedia/Code/ArticleViewController.swift b/Wikipedia/Code/ArticleViewController.swift index 0eec0c6b922..93a6b06ef7b 100644 --- a/Wikipedia/Code/ArticleViewController.swift +++ b/Wikipedia/Code/ArticleViewController.swift @@ -1039,7 +1039,7 @@ private extension ArticleViewController { } var isWidgetCachedFeaturedArticle: Bool { - let sharedCache = SharedContainerCache(fileName: "Widget Cache", defaultCache: { WidgetCache(settings: .default, featuredContent: nil) }) + let sharedCache = SharedContainerCache(fileName: SharedContainerCacheCommonNames.widgetCache, defaultCache: { WidgetCache(settings: .default, featuredContent: nil) }) guard let widgetFeaturedArticleURLString = sharedCache.loadCache().featuredContent?.featuredArticle?.contentURL.desktop.page, let widgetFeaturedArticleURL = URL(string: widgetFeaturedArticleURLString) else { return false diff --git a/Wikipedia/Code/HelpViewController.swift b/Wikipedia/Code/HelpViewController.swift index a6170f4fc5d..8c90096a89f 100644 --- a/Wikipedia/Code/HelpViewController.swift +++ b/Wikipedia/Code/HelpViewController.swift @@ -205,11 +205,11 @@ private extension HelpViewController { urlsToRemove.append(temporaryAppContainerURL.appendingPathComponent("Event Logging")) urlsToRemove.append(temporaryAppContainerURL.appendingPathComponent("Event Platform")) urlsToRemove.append(temporaryAppContainerURL.appendingPathComponent("Library")) - urlsToRemove.append(temporaryAppContainerURL.appendingPathComponent("Push Notifications Cache").appendingPathExtension("json")) + urlsToRemove.append(temporaryAppContainerURL.appendingPathComponent(SharedContainerCacheCommonNames.pushNotificationsCache).appendingPathExtension("json")) urlsToRemove.append(temporaryAppContainerURL.appendingPathComponent("RemoteNotifications").appendingPathExtension("sqlite")) urlsToRemove.append(temporaryAppContainerURL.appendingPathComponent("RemoteNotifications").appendingPathExtension("sqlite-shm")) urlsToRemove.append(temporaryAppContainerURL.appendingPathComponent("RemoteNotifications").appendingPathExtension("sqlite-wal")) - urlsToRemove.append(temporaryAppContainerURL.appendingPathComponent("Widget Cache").appendingPathExtension("json")) + urlsToRemove.append(temporaryAppContainerURL.appendingPathComponent(SharedContainerCacheCommonNames.widgetCache).appendingPathExtension("json")) for url in urlsToRemove { do { try fileManager.removeItem(at: url)