File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 2121* [*] Add scroll-to-top button to Reader streams [#23957]
2222* [*] Add a quick way to replace a featured image for a post [#23962]
2323* [*] Fix an issue with posts in Reader sometimes showing incorrect covers [#23914]
24+ * [*] Fix non-stable order in Posts and Pages section in Stats [#23915]
2425
252625.6
2627-----
Original file line number Diff line number Diff line change @@ -895,12 +895,24 @@ private extension StatsPeriodStore {
895895 }
896896 }
897897
898- private func receivedPostsAndPages( _ postsAndPages : StatsTopPostsTimeIntervalData ? , _ error: Error ? ) {
898+ private func receivedPostsAndPages( _ data : StatsTopPostsTimeIntervalData ? , _ error: Error ? ) {
899899 transaction { state in
900900 state. topPostsAndPagesStatus = error != nil ? . error : . success
901901
902- if postsAndPages != nil {
903- state. topPostsAndPages = postsAndPages
902+ if let data {
903+ let sortedTopPosts = data. topPosts. sorted { lhs, rhs in
904+ if lhs. viewsCount == rhs. viewsCount {
905+ return lhs. title. localizedCaseInsensitiveCompare ( rhs. title) == . orderedAscending
906+ }
907+ return lhs. viewsCount > rhs. viewsCount
908+ }
909+ state. topPostsAndPages = StatsTopPostsTimeIntervalData (
910+ period: data. period,
911+ periodEndDate: data. periodEndDate,
912+ topPosts: sortedTopPosts,
913+ totalViewsCount: data. totalViewsCount,
914+ otherViewsCount: data. otherViewsCount
915+ )
904916 }
905917 }
906918 }
You can’t perform that action at this time.
0 commit comments