mirror of https://github.com/ppy/osu
update var names and test logic
This commit is contained in:
parent
8eeb5ae06b
commit
19a4cef113
|
@ -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 @@ public CollectionButton(BeatmapInfo beatmapInfo)
|
|||
: 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 @@ protected override void LoadComplete()
|
|||
{
|
||||
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 @@ protected override void Dispose(bool isDisposing)
|
|||
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);
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
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 @@ public bool HandleRequest(APIRequest request, APIUser localUser, BeatmapManager
|
|||
|
||||
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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue