From 5821a16ca722c6be837bf4c42755007ce24b8807 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Thu, 26 Sep 2019 16:41:10 -0400 Subject: [PATCH] Add default request ranges for when Link header is not returned --- Tusker/Screens/Profile/ProfileTableViewController.swift | 8 ++++---- Tusker/Screens/Timeline/TimelineTableViewController.swift | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Tusker/Screens/Profile/ProfileTableViewController.swift b/Tusker/Screens/Profile/ProfileTableViewController.swift index c8264728..91997a40 100644 --- a/Tusker/Screens/Profile/ProfileTableViewController.swift +++ b/Tusker/Screens/Profile/ProfileTableViewController.swift @@ -157,8 +157,8 @@ class ProfileTableViewController: EnhancedTableViewController { override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { if timelineSegments.count > 0 && indexPath.section == timelineSegments.count && indexPath.row == timelineSegments[indexPath.section - 1].count - 1 { - guard let older = older else { return } - + let older = self.older ?? RequestRange.after(id: timelineSegments.last!.last!, count: nil) + getStatuses(for: older) { response in guard case let .success(newStatuses, pagination) = response else { fatalError() } @@ -183,8 +183,8 @@ class ProfileTableViewController: EnhancedTableViewController { } @objc func refreshStatuses(_ sender: Any) { - guard let newer = newer else { return } - + let newer = self.newer ?? RequestRange.after(id: timelineSegments.first!.first!, count: nil) + getStatuses(for: newer) { response in guard case let .success(newStatuses, pagination) = response else { fatalError() } diff --git a/Tusker/Screens/Timeline/TimelineTableViewController.swift b/Tusker/Screens/Timeline/TimelineTableViewController.swift index 83b2db5f..ba0780fb 100644 --- a/Tusker/Screens/Timeline/TimelineTableViewController.swift +++ b/Tusker/Screens/Timeline/TimelineTableViewController.swift @@ -36,7 +36,7 @@ class TimelineTableViewController: EnhancedTableViewController { var newer: RequestRange? var older: RequestRange? - + init(for timeline: Timeline) { self.timeline = timeline @@ -105,7 +105,7 @@ class TimelineTableViewController: EnhancedTableViewController { override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { if indexPath.section == timelineSegments.count - 1, indexPath.row == timelineSegments[indexPath.section].count - 1 { - guard let older = older else { return } + let older = self.older ?? RequestRange.before(id: timelineSegments.last!.last!, count: nil) let request = MastodonController.client.getStatuses(timeline: timeline, range: older) MastodonController.client.run(request) { response in @@ -130,7 +130,7 @@ class TimelineTableViewController: EnhancedTableViewController { } @objc func refreshStatuses(_ sender: Any) { - guard let newer = newer else { return } + let newer = self.newer ?? RequestRange.after(id: timelineSegments.first!.first!, count: nil) let request = MastodonController.client.getStatuses(timeline: timeline, range: newer) MastodonController.client.run(request) { response in