1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 09:02:58 +08:00

Merge pull request #22449 from Joehuu/fix-clicking-metadata-relevance-sort

Fix beatmap listing potentially not sorting by relevance when searching via metadata
This commit is contained in:
Dean Herbert 2023-02-02 01:15:36 +09:00 committed by GitHub
commit a8a6a28422
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 6 deletions

View File

@ -563,6 +563,18 @@ namespace osu.Game.Tests.Visual.Navigation
AddUntilStep("featured artist filter is off", () => !getBeatmapListingOverlay().ChildrenOfType<BeatmapSearchGeneralFilterRow>().First().Current.Contains(SearchGeneral.FeaturedArtists));
}
[Test]
public void TestBeatmapListingLinkSearchOnInitialOpen()
{
BeatmapListingOverlay getBeatmapListingOverlay() => Game.ChildrenOfType<BeatmapListingOverlay>().FirstOrDefault();
AddStep("open beatmap overlay with test query", () => Game.SearchBeatmapSet("test"));
AddUntilStep("wait for beatmap overlay to load", () => getBeatmapListingOverlay()?.State.Value == Visibility.Visible);
AddAssert("beatmap overlay sorted by relevance", () => getBeatmapListingOverlay().ChildrenOfType<BeatmapListingSortTabControl>().Single().Current.Value == SortCriteria.Relevance);
}
[Test]
public void TestMainOverlaysClosesNotificationOverlay()
{

View File

@ -17,18 +17,21 @@ namespace osu.Game.Overlays.BeatmapListing
{
public readonly Bindable<SortDirection> SortDirection = new Bindable<SortDirection>(Overlays.SortDirection.Descending);
private SearchCategory? lastCategory;
private bool? lastHasQuery;
private (SearchCategory category, bool hasQuery)? currentParameters;
protected override void LoadComplete()
{
base.LoadComplete();
Reset(SearchCategory.Leaderboard, false);
if (currentParameters == null)
Reset(SearchCategory.Leaderboard, false);
}
public void Reset(SearchCategory category, bool hasQuery)
{
if (category != lastCategory || hasQuery != lastHasQuery)
var newParameters = (category, hasQuery);
if (currentParameters != newParameters)
{
TabControl.Clear();
@ -63,8 +66,7 @@ namespace osu.Game.Overlays.BeatmapListing
// see: https://github.com/ppy/osu-framework/issues/5412
TabControl.Current.TriggerChange();
lastCategory = category;
lastHasQuery = hasQuery;
currentParameters = newParameters;
}
protected override SortTabControl CreateControl() => new BeatmapSortTabControl