Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 2a46011

Browse files
committed
Fix for "Mentioned issues are not sorted by date" (#2649)
1 parent f0a62aa commit 2a46011

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Diff for: Classes/Notifications/NotificationModelController.swift

+11-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ extension NotificationViewModel {
2424
}
2525
}
2626

27+
// sorting Array<InboxDashboardModel> by date for mentioned filter type
28+
extension Array where Element == InboxDashboardModel {
29+
func sortedMentionedByDate(_ predicate: Bool = true, filter: V3IssuesRequest.FilterType) -> [Element] {
30+
if predicate && filter == .mentioned { return self.sorted(by: { $0.date > $1.date }) }
31+
return self
32+
}
33+
}
34+
2735
final class NotificationModelController {
2836

2937
let githubClient: GithubClient
@@ -273,8 +281,9 @@ final class NotificationModelController {
273281
state: state
274282
)
275283
}
276-
cache.set(values: parsed)
277-
completion(.success((parsed, data.next)))
284+
let sorted = parsed.sortedMentionedByDate(true, filter: mapped)
285+
cache.set(values: sorted)
286+
completion(.success((sorted, data.next)))
278287
}
279288
})
280289
}

0 commit comments

Comments
 (0)