1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 23:53:21 +08:00

Move toggle code into own method for readability

This commit is contained in:
Dean Herbert 2021-11-08 21:39:16 +09:00
parent 9a2425f316
commit 72489b32f9

View File

@ -27,16 +27,24 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
private PostBeatmapFavouriteRequest favouriteRequest;
[Resolved]
private IAPIProvider api { get; set; }
public FavouriteButton(APIBeatmapSet beatmapSet)
{
current = new BindableWithCurrent<BeatmapSetFavouriteState>(new BeatmapSetFavouriteState(beatmapSet.HasFavourited, beatmapSet.FavouriteCount));
onlineBeatmapID = beatmapSet.OnlineID;
}
[BackgroundDependencyLoader]
private void load(IAPIProvider api)
protected override void LoadComplete()
{
Action = () =>
base.LoadComplete();
Action = toggleFavouriteStatus;
current.BindValueChanged(_ => updateState(), true);
}
private void toggleFavouriteStatus()
{
var actionType = current.Value.Favourited ? BeatmapFavouriteAction.UnFavourite : BeatmapFavouriteAction.Favourite;
@ -59,13 +67,6 @@ namespace osu.Game.Beatmaps.Drawables.Cards.Buttons
};
api.Queue(favouriteRequest);
};
}
protected override void LoadComplete()
{
base.LoadComplete();
current.BindValueChanged(_ => updateState(), true);
}
private void updateState()