mirror of
https://github.com/ppy/osu.git
synced 2025-01-19 12:22:57 +08:00
Filter out duplicated cards using custom equality comparer instead
This commit is contained in:
parent
bd512c4937
commit
ce5aacb760
@ -180,7 +180,7 @@ namespace osu.Game.Overlays
|
||||
// new results may contain beatmaps from a previous page,
|
||||
// this is dodgy but matches web behaviour for now.
|
||||
// see: https://github.com/ppy/osu-web/issues/9270
|
||||
newCards = newCards.Except(foundContent);
|
||||
newCards = newCards.Except(foundContent, BeatmapCardEqualityComparer.Default);
|
||||
|
||||
panelLoadTask = LoadComponentsAsync(newCards, loaded =>
|
||||
{
|
||||
@ -394,5 +394,21 @@ namespace osu.Game.Overlays
|
||||
if (shouldShowMore)
|
||||
filterControl.FetchNextPage();
|
||||
}
|
||||
|
||||
private class BeatmapCardEqualityComparer : IEqualityComparer<BeatmapCard>
|
||||
{
|
||||
public static BeatmapCardEqualityComparer Default { get; } = new BeatmapCardEqualityComparer();
|
||||
|
||||
public bool Equals(BeatmapCard x, BeatmapCard y)
|
||||
{
|
||||
if (ReferenceEquals(x, y)) return true;
|
||||
if (ReferenceEquals(x, null)) return false;
|
||||
if (ReferenceEquals(y, null)) return false;
|
||||
|
||||
return x.BeatmapSet.Equals(y.BeatmapSet);
|
||||
}
|
||||
|
||||
public int GetHashCode(BeatmapCard obj) => obj.BeatmapSet.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user