diff --git a/Tusker/Screens/Notifications/NotificationsTableViewController.swift b/Tusker/Screens/Notifications/NotificationsTableViewController.swift index 6e32353e..45d4beb0 100644 --- a/Tusker/Screens/Notifications/NotificationsTableViewController.swift +++ b/Tusker/Screens/Notifications/NotificationsTableViewController.swift @@ -107,11 +107,13 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController< case let .failure(error): completion(.failure(.client(error))) - case let .success(notifications, pagination): + case let .success(notifications, _): let groups = NotificationGroup.createGroups(notifications: notifications, only: self.groupTypes) - self.newer = pagination?.newer - self.older = pagination?.older + if !notifications.isEmpty { + self.newer = .after(id: notifications.first!.id, count: nil) + self.older = .before(id: notifications.last!.id, count: nil) + } self.mastodonController.persistentContainer.addAll(notifications: notifications) { var snapshot = Snapshot() @@ -135,9 +137,9 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController< case let .failure(error): completion(.failure(.client(error))) - case let .success(newNotifications, pagination): - if let older = pagination?.older { - self.older = older + case let .success(newNotifications, _): + if !newNotifications.isEmpty { + self.older = .before(id: newNotifications.last!.id, count: nil) } let olderGroups = NotificationGroup.createGroups(notifications: newNotifications, only: self.groupTypes) @@ -166,15 +168,13 @@ class NotificationsTableViewController: DiffableTimelineLikeTableViewController< case let .failure(error): completion(.failure(.client(error))) - case let .success(newNotifications, pagination): + case let .success(newNotifications, _): guard !newNotifications.isEmpty else { completion(.failure(.allCaughtUp)) return } - if let newer = pagination?.newer { - self.newer = newer - } + self.newer = .after(id: newNotifications.first!.id, count: nil) let newerGroups = NotificationGroup.createGroups(notifications: newNotifications, only: self.groupTypes)