Skip to content

Commit

Permalink
Merge pull request #1159 from wikimedia/bug/top_read_follow_on
Browse files Browse the repository at this point in the history
bring back the top read previous date lookup
  • Loading branch information
coreyfloyd authored Jan 5, 2017
2 parents 62fa55e + c575ac7 commit d3ecdb7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions TopReadWidget/WMFTodayTopReadWidgetViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -370,15 +370,23 @@ class WMFTodayTopReadWidgetViewController: UIViewController, NCWidgetProviding {
return
}

guard attempt < 3 else {
guard attempt < 4 else {
completionHandler(.noData)
return
}
contentSource.loadContent(for: date, force: false) {
DispatchQueue.main.async(execute: {
guard self.updateUIWithTopReadFromContentStoreForSiteURL(siteURL: siteURL, date: date) else {
let todayUTC = (date as NSDate).wmf_midnightLocalDateForEquivalentUTC as Date
self.fetch(siteURL: siteURL, date: todayUTC, attempt: attempt + 1, completionHandler: completionHandler)
if (attempt == 1) {
let todayUTC = (date as NSDate).wmf_midnightLocalDateForEquivalentUTC as Date
self.fetch(siteURL: siteURL, date: todayUTC, attempt: attempt + 1, completionHandler: completionHandler)
} else {
guard let previousDate = NSCalendar.wmf_gregorian().date(byAdding: .day, value: -1, to: date, options: .matchStrictly) else {
completionHandler(.noData)
return
}
self.fetch(siteURL: siteURL, date: previousDate, attempt: attempt + 1, completionHandler: completionHandler)
}
return
}

Expand Down

0 comments on commit d3ecdb7

Please sign in to comment.