mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 05:42:56 +08:00
Fix news sidebar assuming returned posts are always from given year
This commit is contained in:
parent
4cad5890c6
commit
b8184a3005
@ -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 }
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user