mirror of
https://github.com/osukey/osukey.git
synced 2025-05-20 21:17:32 +09:00
Implement reporting flow
This commit is contained in:
parent
7251d41deb
commit
3e9fd4c08c
@ -27,6 +27,7 @@ using osu.Game.Online.API;
|
|||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Overlays.Comments.Buttons;
|
using osu.Game.Overlays.Comments.Buttons;
|
||||||
using osu.Game.Overlays.Dialog;
|
using osu.Game.Overlays.Dialog;
|
||||||
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Comments
|
namespace osu.Game.Overlays.Comments
|
||||||
@ -73,6 +74,9 @@ namespace osu.Game.Overlays.Comments
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; } = null!;
|
private IAPIProvider api { get; set; } = null!;
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private NotificationOverlay? notificationOverlay { get; set; }
|
||||||
|
|
||||||
public DrawableComment(Comment comment)
|
public DrawableComment(Comment comment)
|
||||||
{
|
{
|
||||||
Comment = comment;
|
Comment = comment;
|
||||||
@ -405,6 +409,28 @@ namespace osu.Game.Overlays.Comments
|
|||||||
api.Queue(request);
|
api.Queue(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ReportComment(CommentReportReason reason, string comment)
|
||||||
|
{
|
||||||
|
actionsContainer.Hide();
|
||||||
|
actionsLoading.Show();
|
||||||
|
var request = new CommentReportRequest(Comment.Id, reason, comment);
|
||||||
|
request.Success += () =>
|
||||||
|
{
|
||||||
|
actionsLoading.Hide();
|
||||||
|
notificationOverlay?.Post(new SimpleNotification
|
||||||
|
{
|
||||||
|
Icon = FontAwesome.Solid.CheckCircle,
|
||||||
|
Text = "The comment reported successfully."
|
||||||
|
});
|
||||||
|
};
|
||||||
|
request.Failure += _ =>
|
||||||
|
{
|
||||||
|
actionsLoading.Hide();
|
||||||
|
actionsContainer.Show();
|
||||||
|
};
|
||||||
|
api.Queue(request);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
ShowDeleted.BindValueChanged(show =>
|
ShowDeleted.BindValueChanged(show =>
|
||||||
@ -549,7 +575,7 @@ namespace osu.Game.Overlays.Comments
|
|||||||
|
|
||||||
public Popover GetPopover()
|
public Popover GetPopover()
|
||||||
{
|
{
|
||||||
return new ReportCommentPopover(Comment.Id);
|
return new ReportCommentPopover(ReportComment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
@ -13,14 +15,14 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
public class ReportCommentPopover : OsuPopover
|
public class ReportCommentPopover : OsuPopover
|
||||||
{
|
{
|
||||||
public readonly long ID;
|
private readonly Action<CommentReportReason, string> action;
|
||||||
private LabelledEnumDropdown<CommentReportReason> reason = null!;
|
private LabelledEnumDropdown<CommentReportReason> reason = null!;
|
||||||
private LabelledTextBox info = null!;
|
private LabelledTextBox info = null!;
|
||||||
private ShakeContainer shaker = null!;
|
private ShakeContainer shaker = null!;
|
||||||
|
|
||||||
public ReportCommentPopover(long id)
|
public ReportCommentPopover(Action<CommentReportReason, string> action)
|
||||||
{
|
{
|
||||||
ID = id;
|
this.action = action;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -73,6 +75,9 @@ namespace osu.Game.Overlays.Comments
|
|||||||
shaker.Shake();
|
shaker.Shake();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.HidePopover();
|
||||||
|
action.Invoke(reasonValue, infoValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user