mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Move toggle code into own method for readability
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user