Skip to content

Commit 4dcc928

Browse files
authored
Merge pull request #33606 from peppy/add-confirmation-for-block
Add confirmation step before blocking a user
2 parents f59df15 + 6383d8c commit 4dcc928

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

osu.Game/Localisation/ContextMenuStrings.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ public static class ContextMenuStrings
2929
/// </summary>
3030
public static LocalisableString SpectatePlayer => new TranslatableString(getKey(@"spectate_player"), @"Spectate");
3131

32+
/// <summary>
33+
/// "Are you sure you want to block {0}?"
34+
/// </summary>
35+
public static LocalisableString ConfirmBlockUser(string username) => new TranslatableString(getKey(@"confirm_block_user"), @"Are you sure you want to block {0}?", username);
36+
37+
/// <summary>
38+
/// "Are you sure you want to unblock {0}?"
39+
/// </summary>
40+
public static LocalisableString ConfirmUnblockUser(string username) => new TranslatableString(getKey(@"confirm_unblock_user"), @"Are you sure you want to unblock {0}?", username);
41+
3242
private static string getKey(string key) => $@"{prefix}:{key}";
3343
}
3444
}

osu.Game/Users/UserPanel.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using osu.Game.Online.API.Requests;
2727
using osu.Game.Online.Metadata;
2828
using osu.Game.Online.Multiplayer;
29+
using osu.Game.Overlays.Dialog;
2930
using osu.Game.Overlays.Notifications;
3031
using osu.Game.Screens;
3132
using osu.Game.Screens.Play;
@@ -68,6 +69,9 @@ protected UserPanel(APIUser user)
6869
[Resolved]
6970
private ChatOverlay? chatOverlay { get; set; }
7071

72+
[Resolved]
73+
private IDialogOverlay? dialogOverlay { get; set; }
74+
7175
[Resolved]
7276
protected OverlayColourProvider? ColourProvider { get; private set; }
7377

@@ -163,9 +167,15 @@ public MenuItem[] ContextMenuItems
163167
chatOverlay?.Show();
164168
}));
165169

166-
items.Add(isUserBlocked()
167-
? new OsuMenuItem(UsersStrings.BlocksButtonUnblock, MenuItemType.Standard, () => toggleBlock(false))
168-
: new OsuMenuItem(UsersStrings.BlocksButtonBlock, MenuItemType.Destructive, () => toggleBlock(true)));
170+
items.Add(!isUserBlocked()
171+
? new OsuMenuItem(UsersStrings.BlocksButtonBlock, MenuItemType.Destructive, () =>
172+
{
173+
dialogOverlay?.Push(new ConfirmBlockActionDialog(ContextMenuStrings.ConfirmBlockUser(User.Username), () => toggleBlock(true)));
174+
})
175+
: new OsuMenuItem(UsersStrings.BlocksButtonUnblock, MenuItemType.Standard, () =>
176+
{
177+
dialogOverlay?.Push(new ConfirmBlockActionDialog(ContextMenuStrings.ConfirmUnblockUser(User.Username), () => toggleBlock(false)));
178+
}));
169179

170180
if (isUserOnline())
171181
{
@@ -228,5 +238,14 @@ public bool MatchingFilter
228238
}
229239

230240
public bool FilteringActive { get; set; }
241+
242+
private partial class ConfirmBlockActionDialog : DangerousActionDialog
243+
{
244+
public ConfirmBlockActionDialog(LocalisableString text, Action? action = null)
245+
{
246+
BodyText = text;
247+
DangerousAction = action;
248+
}
249+
}
231250
}
232251
}

0 commit comments

Comments
 (0)