mirror of
https://github.com/osukey/osukey.git
synced 2025-06-08 12:58:01 +09:00
Handle hitting the maximum allowed number of favourited beatmaps
This commit is contained in:
parent
4f356f3aeb
commit
2dac3a6efe
@ -11,6 +11,7 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
|
using osu.Game.Overlays.Notifications;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.BeatmapSet.Buttons
|
namespace osu.Game.Overlays.BeatmapSet.Buttons
|
||||||
@ -26,8 +27,8 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
|||||||
|
|
||||||
public string TooltipText => (favourited.Value ? "Unfavourite" : "Favourite") + " this beatmapset";
|
public string TooltipText => (favourited.Value ? "Unfavourite" : "Favourite") + " this beatmapset";
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(IAPIProvider api)
|
private void load(IAPIProvider api, NotificationOverlay notifications)
|
||||||
{
|
{
|
||||||
SpriteIcon icon;
|
SpriteIcon icon;
|
||||||
AddRange(new Drawable[]
|
AddRange(new Drawable[]
|
||||||
@ -68,6 +69,18 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
|||||||
request?.Cancel();
|
request?.Cancel();
|
||||||
request = new PostBeatmapFavouriteRequest(BeatmapSet.Value?.OnlineBeatmapSetID ?? 0, favourited.Value ? BeatmapFavouriteAction.UnFavourite : BeatmapFavouriteAction.Favourite);
|
request = new PostBeatmapFavouriteRequest(BeatmapSet.Value?.OnlineBeatmapSetID ?? 0, favourited.Value ? BeatmapFavouriteAction.UnFavourite : BeatmapFavouriteAction.Favourite);
|
||||||
request.Success += () => favourited.Value = !favourited.Value;
|
request.Success += () => favourited.Value = !favourited.Value;
|
||||||
|
request.Failure += exception =>
|
||||||
|
{
|
||||||
|
if (exception.Message == "UnprocessableEntity")
|
||||||
|
{
|
||||||
|
notifications.Post(new SimpleNotification
|
||||||
|
{
|
||||||
|
Text = @"You have too many favourited beatmaps! Please unfavourite some before trying again.",
|
||||||
|
Icon = FontAwesome.Solid.Times,
|
||||||
|
});
|
||||||
|
loading.Hide();
|
||||||
|
}
|
||||||
|
};
|
||||||
api.Queue(request);
|
api.Queue(request);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user