Browse Source

Add default request ranges for when Link header is not returned

pixelfed
Shadowfacts 2 years ago
parent
commit
5821a16ca7
Signed by: shadowfacts GPG Key ID: 94A5AB95422746E5
  1. 8
      Tusker/Screens/Profile/ProfileTableViewController.swift
  2. 6
      Tusker/Screens/Timeline/TimelineTableViewController.swift

8
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() }

6
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

Loading…
Cancel
Save