1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 22:33:05 +08:00

Merge pull request #20066 from peppy/fix-filtering-with-date-modes

Fix "date submitted" and "date ranked" filtering not working as intended
This commit is contained in:
Dan Balasescu 2022-09-01 22:01:49 +09:00 committed by GitHub
commit 5ca6395295
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 4 deletions

View File

@ -494,6 +494,43 @@ namespace osu.Game.Tests.Visual.SongSelect
AddAssert("Something is selected", () => carousel.SelectedBeatmapInfo != null); AddAssert("Something is selected", () => carousel.SelectedBeatmapInfo != null);
} }
[Test]
public void TestSortingDateSubmitted()
{
var sets = new List<BeatmapSetInfo>();
const string zzz_string = "zzzzz";
AddStep("Populuate beatmap sets", () =>
{
sets.Clear();
for (int i = 0; i < 20; i++)
{
var set = TestResources.CreateTestBeatmapSetInfo(5);
if (i >= 2 && i < 10)
set.DateSubmitted = DateTimeOffset.Now.AddMinutes(i);
if (i < 5)
set.Beatmaps.ForEach(b => b.Metadata.Artist = zzz_string);
sets.Add(set);
}
});
loadBeatmaps(sets);
AddStep("Sort by date submitted", () => carousel.Filter(new FilterCriteria { Sort = SortMode.DateSubmitted }, false));
checkVisibleItemCount(diff: false, count: 8);
checkVisibleItemCount(diff: true, count: 5);
AddStep("Sort by date submitted and string", () => carousel.Filter(new FilterCriteria
{
Sort = SortMode.DateSubmitted,
SearchText = zzz_string
}, false));
checkVisibleItemCount(diff: false, count: 3);
checkVisibleItemCount(diff: true, count: 5);
}
[Test] [Test]
public void TestSorting() public void TestSorting()
{ {

View File

@ -129,12 +129,13 @@ namespace osu.Game.Screens.Select.Carousel
public override void Filter(FilterCriteria criteria) public override void Filter(FilterCriteria criteria)
{ {
base.Filter(criteria); base.Filter(criteria);
bool match = Items.All(i => i.Filtered.Value);
match &= criteria.Sort != SortMode.DateRanked || BeatmapSet?.DateRanked != null; bool filtered = Items.All(i => i.Filtered.Value);
match &= criteria.Sort != SortMode.DateSubmitted || BeatmapSet?.DateSubmitted != null;
Filtered.Value = match; filtered |= criteria.Sort == SortMode.DateRanked && BeatmapSet?.DateRanked == null;
filtered |= criteria.Sort == SortMode.DateSubmitted && BeatmapSet?.DateSubmitted == null;
Filtered.Value = filtered;
} }
public override string ToString() => BeatmapSet.ToString(); public override string ToString() => BeatmapSet.ToString();