1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 09:02:55 +08:00

Fix news sidebar assuming returned posts are always from given year

This commit is contained in:
Bartłomiej Dach 2022-01-19 23:13:30 +01:00
parent 4cad5890c6
commit b8184a3005
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -56,19 +56,17 @@ namespace osu.Game.Overlays.News.Sidebar
if (allPosts?.Any() != true) if (allPosts?.Any() != true)
return; return;
var lookup = metadata.NewValue.NewsPosts.ToLookup(post => post.PublishedAt.Month); var lookup = metadata.NewValue.NewsPosts.ToLookup(post => (post.PublishedAt.Month, post.PublishedAt.Year));
var keys = lookup.Select(kvp => kvp.Key); var keys = lookup.Select(kvp => kvp.Key);
var sortedKeys = keys.OrderByDescending(k => k).ToList(); var sortedKeys = keys.OrderByDescending(k => k.Year).ThenByDescending(k => k.Month).ToList();
int year = metadata.NewValue.CurrentYear;
for (int i = 0; i < sortedKeys.Count; i++) for (int i = 0; i < sortedKeys.Count; i++)
{ {
int month = sortedKeys[i]; var key = sortedKeys[i];
var posts = lookup[month]; var posts = lookup[key];
monthsFlow.Add(new MonthSection(month, year, posts) monthsFlow.Add(new MonthSection(key.Month, key.Year, posts)
{ {
Expanded = { Value = i == 0 } Expanded = { Value = i == 0 }
}); });