diff --git a/Classes/Notifications/NotificationModelController.swift b/Classes/Notifications/NotificationModelController.swift index 9a962eb9a..f1989d9fa 100644 --- a/Classes/Notifications/NotificationModelController.swift +++ b/Classes/Notifications/NotificationModelController.swift @@ -24,6 +24,14 @@ extension NotificationViewModel { } } +// sorting Array by date for mentioned filter type +extension Array where Element == InboxDashboardModel { + func sortedMentionedByDate(_ predicate: Bool = true, filter: V3IssuesRequest.FilterType) -> [Element] { + if predicate && filter == .mentioned { return self.sorted(by: { $0.date > $1.date }) } + return self + } +} + final class NotificationModelController { let githubClient: GithubClient @@ -273,8 +281,9 @@ final class NotificationModelController { state: state ) } - cache.set(values: parsed) - completion(.success((parsed, data.next))) + let sorted = parsed.sortedMentionedByDate(true, filter: mapped) + cache.set(values: sorted) + completion(.success((sorted, data.next))) } }) }