forked from shadowfacts/Tusker
Fix refreshing multiple times with no new data not working
When the requested range has no results, no pagination data is returned, so the existing `newer` request range is replaced with nil. As there was no new data, the existing request range is still correct and should not be replaced. Fixes #75
This commit is contained in:
parent
ec2062ad42
commit
db4312ee34
|
@ -208,8 +208,10 @@ class NotificationsTableViewController: EnhancedTableViewController {
|
||||||
MastodonCache.addAll(statuses: newNotifications.compactMap { $0.status })
|
MastodonCache.addAll(statuses: newNotifications.compactMap { $0.status })
|
||||||
MastodonCache.addAll(accounts: newNotifications.map { $0.account })
|
MastodonCache.addAll(accounts: newNotifications.map { $0.account })
|
||||||
|
|
||||||
self.newer = pagination?.newer
|
if let newer = pagination?.newer {
|
||||||
|
self.newer = newer
|
||||||
|
}
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.refreshControl?.endRefreshing()
|
self.refreshControl?.endRefreshing()
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,9 @@ class ProfileTableViewController: EnhancedTableViewController {
|
||||||
MastodonCache.addAll(statuses: newStatuses)
|
MastodonCache.addAll(statuses: newStatuses)
|
||||||
self.timelineSegments[0].insert(contentsOf: newStatuses.map { ($0.id, .unknown) }, at: 0)
|
self.timelineSegments[0].insert(contentsOf: newStatuses.map { ($0.id, .unknown) }, at: 0)
|
||||||
|
|
||||||
self.newer = pagination?.newer
|
if let newer = pagination?.newer {
|
||||||
|
self.newer = newer
|
||||||
|
}
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.refreshControl?.endRefreshing()
|
self.refreshControl?.endRefreshing()
|
||||||
|
|
|
@ -127,9 +127,14 @@ class TimelineTableViewController: EnhancedTableViewController {
|
||||||
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
|
||||||
guard case let .success(newStatuses, pagination) = response else { fatalError() }
|
guard case let .success(newStatuses, pagination) = response else { fatalError() }
|
||||||
self.newer = pagination?.newer
|
|
||||||
MastodonCache.addAll(statuses: newStatuses)
|
MastodonCache.addAll(statuses: newStatuses)
|
||||||
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 let newer = pagination?.newer {
|
||||||
|
self.newer = newer
|
||||||
|
}
|
||||||
|
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self.refreshControl?.endRefreshing()
|
self.refreshControl?.endRefreshing()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue