mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:03:22 +08: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.Overlays.Comments.Buttons;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
|
||||
namespace osu.Game.Overlays.Comments
|
||||
@ -73,6 +74,9 @@ namespace osu.Game.Overlays.Comments
|
||||
[Resolved]
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private NotificationOverlay? notificationOverlay { get; set; }
|
||||
|
||||
public DrawableComment(Comment comment)
|
||||
{
|
||||
Comment = comment;
|
||||
@ -405,6 +409,28 @@ namespace osu.Game.Overlays.Comments
|
||||
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()
|
||||
{
|
||||
ShowDeleted.BindValueChanged(show =>
|
||||
@ -549,7 +575,7 @@ namespace osu.Game.Overlays.Comments
|
||||
|
||||
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.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
@ -13,14 +15,14 @@ namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
public class ReportCommentPopover : OsuPopover
|
||||
{
|
||||
public readonly long ID;
|
||||
private readonly Action<CommentReportReason, string> action;
|
||||
private LabelledEnumDropdown<CommentReportReason> reason = null!;
|
||||
private LabelledTextBox info = null!;
|
||||
private ShakeContainer shaker = null!;
|
||||
|
||||
public ReportCommentPopover(long id)
|
||||
public ReportCommentPopover(Action<CommentReportReason, string> action)
|
||||
{
|
||||
ID = id;
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -73,6 +75,9 @@ namespace osu.Game.Overlays.Comments
|
||||
shaker.Shake();
|
||||
return;
|
||||
}
|
||||
|
||||
this.HidePopover();
|
||||
action.Invoke(reasonValue, infoValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user