Fix not being able to refresh timelines
This commit is contained in:
parent
2825345c7e
commit
db30471011
|
@ -213,15 +213,17 @@ class TimelineTableViewController: EnhancedTableViewController {
|
||||||
let request = Client.getStatuses(timeline: timeline, range: newer)
|
let request = Client.getStatuses(timeline: timeline, range: newer)
|
||||||
mastodonController.run(request) { response in
|
mastodonController.run(request) { response in
|
||||||
guard case let .success(newStatuses, pagination) = response else { fatalError() }
|
guard case let .success(newStatuses, pagination) = response else { fatalError() }
|
||||||
self.newer = pagination?.newer
|
|
||||||
self.timelineSegments[0].insert(contentsOf: newStatuses.map { ($0.id, .unknown) }, at: 0)
|
self.timelineSegments[0].insert(contentsOf: newStatuses.map { ($0.id, .unknown) }, at: 0)
|
||||||
|
|
||||||
|
// If there is no new newer pagination, don't reset it, so that the user can continue refreshing for more recent statuses
|
||||||
|
// Otherwise, when no new statuses were loaded, it would get reset and the the user would be unable to refresh
|
||||||
if let newer = pagination?.newer {
|
if let newer = pagination?.newer {
|
||||||
self.newer = newer
|
self.newer = newer
|
||||||
}
|
}
|
||||||
|
|
||||||
self.mastodonController.persistentContainer.addAll(statuses: newStatuses) {
|
self.mastodonController.persistentContainer.addAll(statuses: newStatuses) {
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
|
self.timelineSegments[0].insert(contentsOf: newStatuses.map { ($0.id, .unknown) }, at: 0)
|
||||||
let newIndexPaths = (0..<newStatuses.count).map {
|
let newIndexPaths = (0..<newStatuses.count).map {
|
||||||
IndexPath(row: $0, section: 0)
|
IndexPath(row: $0, section: 0)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue