Skip to content

Commit

Permalink
invalid cache when fetching feature content failed.
Browse files Browse the repository at this point in the history
  • Loading branch information
ngn999 committed Nov 1, 2024
1 parent d4cab24 commit baca6a0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions WMF Framework/Widget/WidgetController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,8 @@ public extension WidgetController {
}
}
} else {
widgetCache.featuredContent = nil
self.sharedCache.saveCache(widgetCache)
performCompletion(result: .failure(.contentFailure))
}
case .failure(let error):
Expand Down Expand Up @@ -373,11 +375,13 @@ public extension WidgetController {
}
}
} else {
widgetCache.featuredContent = featuredContent
self.sharedCache.saveCache(widgetCache)
if let featureArticle = featuredContent.featuredArticle {
widgetCache.featuredContent = featuredContent
self.sharedCache.saveCache(widgetCache)
performCompletion(result: .success(featureArticle))
} else {
widgetCache.featuredContent = nil
self.sharedCache.saveCache(widgetCache)
performCompletion(result: .failure(.contentFailure))
}
}
Expand Down Expand Up @@ -427,7 +431,7 @@ public extension WidgetController {
}
}
} else {
widgetCache.featuredContent = featuredContent
widgetCache.featuredContent = nil
self.sharedCache.saveCache(widgetCache)
performCompletion(result: .failure(.contentFailure))
}
Expand Down

0 comments on commit baca6a0

Please sign in to comment.