1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 06:47:24 +08:00

update var names and test logic

This commit is contained in:
Layendan 2024-08-01 02:52:41 -07:00
parent 8eeb5ae06b
commit 19a4cef113
2 changed files with 11 additions and 9 deletions

View File

@ -23,7 +23,7 @@ namespace osu.Game.Screens.Ranking
public partial class CollectionButton : GrayButton, IHasPopover
{
private readonly BeatmapInfo beatmapInfo;
private readonly Bindable<bool> current;
private readonly Bindable<bool> isInAnyCollection;
[Resolved]
private RealmAccess realmAccess { get; set; } = null!;
@ -37,7 +37,7 @@ namespace osu.Game.Screens.Ranking
: base(FontAwesome.Solid.Book)
{
this.beatmapInfo = beatmapInfo;
current = new Bindable<bool>(false);
isInAnyCollection = new Bindable<bool>(false);
Size = new Vector2(75, 30);
@ -54,9 +54,9 @@ namespace osu.Game.Screens.Ranking
{
base.LoadComplete();
collectionSubscription = realmAccess.RegisterForNotifications(r => r.All<BeatmapCollection>(), updateRealm);
collectionSubscription = realmAccess.RegisterForNotifications(r => r.All<BeatmapCollection>(), collectionsChanged);
current.BindValueChanged(_ => updateState(), true);
isInAnyCollection.BindValueChanged(_ => updateState(), true);
}
protected override void Dispose(bool isDisposing)
@ -66,14 +66,14 @@ namespace osu.Game.Screens.Ranking
collectionSubscription?.Dispose();
}
private void updateRealm(IRealmCollection<BeatmapCollection> sender, ChangeSet? changes)
private void collectionsChanged(IRealmCollection<BeatmapCollection> sender, ChangeSet? changes)
{
current.Value = sender.AsEnumerable().Any(c => c.BeatmapMD5Hashes.Contains(beatmapInfo.MD5Hash));
isInAnyCollection.Value = sender.AsEnumerable().Any(c => c.BeatmapMD5Hashes.Contains(beatmapInfo.MD5Hash));
}
private void updateState()
{
Background.FadeColour(current.Value ? colours.Green : colours.Gray4, 500, Easing.InOutExpo);
Background.FadeColour(isInAnyCollection.Value ? colours.Green : colours.Gray4, 500, Easing.InOutExpo);
}
public Popover GetPopover() => new CollectionPopover(beatmapInfo);

View File

@ -9,6 +9,7 @@ using System.Diagnostics;
using System.Linq;
using Newtonsoft.Json;
using osu.Game.Beatmaps;
using osu.Game.Database;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
@ -197,8 +198,9 @@ namespace osu.Game.Tests.Visual.OnlinePlay
case GetBeatmapSetRequest getBeatmapSetRequest:
{
// Incorrect logic, see https://github.com/ppy/osu/pull/28991#issuecomment-2256721076 for reason why this change
var baseBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineID == getBeatmapSetRequest.ID);
var baseBeatmap = getBeatmapSetRequest.Type == BeatmapSetLookupType.BeatmapId
? beatmapManager.QueryBeatmap(b => b.OnlineID == getBeatmapSetRequest.ID)
: beatmapManager.QueryBeatmapSet(s => s.OnlineID == getBeatmapSetRequest.ID)?.PerformRead(s => s.Beatmaps.First().Detach());
if (baseBeatmap == null)
{