Add default request ranges for when Link header is not returned

This commit is contained in:
Shadowfacts 2019-09-26 16:41:10 -04:00
parent bd81c81500
commit 5821a16ca7
Signed by untrusted user: shadowfacts
GPG Key ID: 94A5AB95422746E5
2 changed files with 7 additions and 7 deletions

View File

@ -157,8 +157,8 @@ class ProfileTableViewController: EnhancedTableViewController {
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { 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 { 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 getStatuses(for: older) { response in
guard case let .success(newStatuses, pagination) = response else { fatalError() } guard case let .success(newStatuses, pagination) = response else { fatalError() }
@ -183,8 +183,8 @@ class ProfileTableViewController: EnhancedTableViewController {
} }
@objc func refreshStatuses(_ sender: Any) { @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 getStatuses(for: newer) { response in
guard case let .success(newStatuses, pagination) = response else { fatalError() } guard case let .success(newStatuses, pagination) = response else { fatalError() }

View File

@ -36,7 +36,7 @@ class TimelineTableViewController: EnhancedTableViewController {
var newer: RequestRange? var newer: RequestRange?
var older: RequestRange? var older: RequestRange?
init(for timeline: Timeline) { init(for timeline: Timeline) {
self.timeline = timeline self.timeline = timeline
@ -105,7 +105,7 @@ class TimelineTableViewController: EnhancedTableViewController {
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
if indexPath.section == timelineSegments.count - 1, if indexPath.section == timelineSegments.count - 1,
indexPath.row == timelineSegments[indexPath.section].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) let request = MastodonController.client.getStatuses(timeline: timeline, range: older)
MastodonController.client.run(request) { response in MastodonController.client.run(request) { response in
@ -130,7 +130,7 @@ class TimelineTableViewController: EnhancedTableViewController {
} }
@objc func refreshStatuses(_ sender: Any) { @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) let request = MastodonController.client.getStatuses(timeline: timeline, range: newer)
MastodonController.client.run(request) { response in MastodonController.client.run(request) { response in