Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
* [*] Add scroll-to-top button to Reader streams [#23957]
* [*] Add a quick way to replace a featured image for a post [#23962]
* [*] Fix an issue with posts in Reader sometimes showing incorrect covers [#23914]
* [*] Fix non-stable order in Posts and Pages section in Stats [#23915]

25.6
-----
Expand Down
18 changes: 15 additions & 3 deletions WordPress/Classes/Stores/StatsPeriodStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -895,12 +895,24 @@ private extension StatsPeriodStore {
}
}

private func receivedPostsAndPages(_ postsAndPages: StatsTopPostsTimeIntervalData?, _ error: Error?) {
private func receivedPostsAndPages(_ data: StatsTopPostsTimeIntervalData?, _ error: Error?) {
transaction { state in
state.topPostsAndPagesStatus = error != nil ? .error : .success

if postsAndPages != nil {
state.topPostsAndPages = postsAndPages
if let data {
let sortedTopPosts = data.topPosts.sorted { lhs, rhs in
if lhs.viewsCount == rhs.viewsCount {
return lhs.title.localizedCaseInsensitiveCompare(rhs.title) == .orderedAscending
}
return lhs.viewsCount > rhs.viewsCount
}
state.topPostsAndPages = StatsTopPostsTimeIntervalData(
period: data.period,
periodEndDate: data.periodEndDate,
topPosts: sortedTopPosts,
totalViewsCount: data.totalViewsCount,
otherViewsCount: data.otherViewsCount
)
}
}
}
Expand Down