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

Commit

Permalink
Fix for "Mentioned issues are not sorted by date" (#2649)
Browse files Browse the repository at this point in the history
  • Loading branch information
akarataev committed Mar 5, 2019
1 parent f0a62aa commit 2a46011
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions Classes/Notifications/NotificationModelController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ extension NotificationViewModel {
}
}

// sorting Array<InboxDashboardModel> 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
Expand Down Expand Up @@ -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)))
}
})
}
Expand Down

0 comments on commit 2a46011

Please sign in to comment.