mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 09:03:50 +09:00
Simplify sorting logic
This commit is contained in:
@ -16,6 +16,7 @@ using osu.Game.Overlays.SearchableList;
|
|||||||
using osu.Game.Overlays.Social;
|
using osu.Game.Overlays.Social;
|
||||||
using osu.Game.Users;
|
using osu.Game.Users;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace osu.Game.Overlays
|
namespace osu.Game.Overlays
|
||||||
{
|
{
|
||||||
@ -188,31 +189,11 @@ namespace osu.Game.Overlays
|
|||||||
switch (Filter.Tabs.Current.Value)
|
switch (Filter.Tabs.Current.Value)
|
||||||
{
|
{
|
||||||
case SocialSortCriteria.Location:
|
case SocialSortCriteria.Location:
|
||||||
switch (sortDirection)
|
sortedUsers = sortBy(sortedUsers, u => u.Country.FullName, sortDirection);
|
||||||
{
|
|
||||||
case SortDirection.Ascending:
|
|
||||||
sortedUsers = sortedUsers.OrderBy(u => u.Country.FullName);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SortDirection.Descending:
|
|
||||||
sortedUsers = sortedUsers.OrderByDescending(u => u.Country.FullName);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SocialSortCriteria.Name:
|
case SocialSortCriteria.Name:
|
||||||
switch (sortDirection)
|
sortedUsers = sortBy(sortedUsers, u => u.Username, sortDirection);
|
||||||
{
|
|
||||||
case SortDirection.Ascending:
|
|
||||||
sortedUsers = sortedUsers.OrderBy(u => u.Username);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SortDirection.Descending:
|
|
||||||
sortedUsers = sortedUsers.OrderByDescending(u => u.Username);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,6 +202,9 @@ namespace osu.Game.Overlays
|
|||||||
recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value);
|
recreatePanels(Filter.DisplayStyleControl.DisplayStyle.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private IEnumerable<User> sortBy<T>(IEnumerable<User> users, Func<User, T> condition, SortDirection sortDirection) =>
|
||||||
|
sortDirection == SortDirection.Ascending ? users.OrderBy(condition) : users.OrderByDescending(condition);
|
||||||
|
|
||||||
private void onDropdownChanged()
|
private void onDropdownChanged()
|
||||||
{
|
{
|
||||||
if (Users == null)
|
if (Users == null)
|
||||||
|
Reference in New Issue
Block a user