Skip to content

Commit

Permalink
PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tonisevener committed Mar 17, 2023
1 parent 6b47971 commit abf44e5
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion WMF Framework/SharedContainerCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Codable>: SharedContainerCacheHousekeepingProtocol {
Expand Down Expand Up @@ -84,7 +85,7 @@ public final class SharedContainerCache<T: Codable>: SharedContainerCacheHouseke

@objc public class SharedContainerCacheClearFeaturedArticleWrapper: NSObject {
@objc public static func clearOutFeaturedArticleWidgetCache() {
let sharedCache = SharedContainerCache<WidgetCache>(fileName: "Widget Cache", defaultCache: { WidgetCache(settings: .default, featuredContent: nil) })
let sharedCache = SharedContainerCache<WidgetCache>(fileName: SharedContainerCacheCommonNames.widgetCache, defaultCache: { WidgetCache(settings: .default, featuredContent: nil) })
var updatedCache = sharedCache.loadCache()
updatedCache.featuredContent = nil
sharedCache.saveCache(updatedCache)
Expand Down
2 changes: 1 addition & 1 deletion WMF Framework/Widget/WidgetController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public final class WidgetController: NSObject {
// MARK: Properties

@objc public static let shared = WidgetController()
private let sharedCache = SharedContainerCache<WidgetCache>(fileName: "Widget Cache", defaultCache: { WidgetCache(settings: .default, featuredContent: nil) })
private let sharedCache = SharedContainerCache<WidgetCache>(fileName: SharedContainerCacheCommonNames.widgetCache, defaultCache: { WidgetCache(settings: .default, featuredContent: nil) })

// MARK: Public

Expand Down
2 changes: 1 addition & 1 deletion Wikipedia/Code/ArticleViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1039,7 +1039,7 @@ private extension ArticleViewController {
}

var isWidgetCachedFeaturedArticle: Bool {
let sharedCache = SharedContainerCache<WidgetCache>(fileName: "Widget Cache", defaultCache: { WidgetCache(settings: .default, featuredContent: nil) })
let sharedCache = SharedContainerCache<WidgetCache>(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
Expand Down
4 changes: 2 additions & 2 deletions Wikipedia/Code/HelpViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit abf44e5

Please sign in to comment.