Fix crash when loading older/newer notifications on Pixelfed
Damn Pixelfed returning nonsensical pagination links Closes #166
This commit is contained in:
parent
facf039f97
commit
92efee6f46
|
@ -107,11 +107,13 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
||||||
case let .failure(error):
|
case let .failure(error):
|
||||||
completion(.failure(.client(error)))
|
completion(.failure(.client(error)))
|
||||||
|
|
||||||
case let .success(notifications, pagination):
|
case let .success(notifications, _):
|
||||||
let groups = NotificationGroup.createGroups(notifications: notifications, only: self.groupTypes)
|
let groups = NotificationGroup.createGroups(notifications: notifications, only: self.groupTypes)
|
||||||
|
|
||||||
self.newer = pagination?.newer
|
if !notifications.isEmpty {
|
||||||
self.older = pagination?.older
|
self.newer = .after(id: notifications.first!.id, count: nil)
|
||||||
|
self.older = .before(id: notifications.last!.id, count: nil)
|
||||||
|
}
|
||||||
|
|
||||||
self.mastodonController.persistentContainer.addAll(notifications: notifications) {
|
self.mastodonController.persistentContainer.addAll(notifications: notifications) {
|
||||||
var snapshot = Snapshot()
|
var snapshot = Snapshot()
|
||||||
|
@ -135,9 +137,9 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
||||||
case let .failure(error):
|
case let .failure(error):
|
||||||
completion(.failure(.client(error)))
|
completion(.failure(.client(error)))
|
||||||
|
|
||||||
case let .success(newNotifications, pagination):
|
case let .success(newNotifications, _):
|
||||||
if let older = pagination?.older {
|
if !newNotifications.isEmpty {
|
||||||
self.older = older
|
self.older = .before(id: newNotifications.last!.id, count: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
let olderGroups = NotificationGroup.createGroups(notifications: newNotifications, only: self.groupTypes)
|
let olderGroups = NotificationGroup.createGroups(notifications: newNotifications, only: self.groupTypes)
|
||||||
|
@ -166,15 +168,13 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController<
|
||||||
case let .failure(error):
|
case let .failure(error):
|
||||||
completion(.failure(.client(error)))
|
completion(.failure(.client(error)))
|
||||||
|
|
||||||
case let .success(newNotifications, pagination):
|
case let .success(newNotifications, _):
|
||||||
guard !newNotifications.isEmpty else {
|
guard !newNotifications.isEmpty else {
|
||||||
completion(.failure(.allCaughtUp))
|
completion(.failure(.allCaughtUp))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if let newer = pagination?.newer {
|
self.newer = .after(id: newNotifications.first!.id, count: nil)
|
||||||
self.newer = newer
|
|
||||||
}
|
|
||||||
|
|
||||||
let newerGroups = NotificationGroup.createGroups(notifications: newNotifications, only: self.groupTypes)
|
let newerGroups = NotificationGroup.createGroups(notifications: newNotifications, only: self.groupTypes)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue