Skip to content

Implement blocking users #32612

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

zihadmahiuddin
Copy link
Contributor

@zihadmahiuddin zihadmahiuddin commented Mar 27, 2025

Closes #32552

This PR adds a context menu item to UserPanel for blocking/unblocking a user.
Currently, blocking a friend from the friend list will remove them from the list, not sure if it should match what the website does instead. I attempted that too but wasn't sure what would be the right place to re-fetch the friend list.
Blocked users are also removed from the "Currently Online" list (according to ppy/osu-server-spectator#264).

I was going to implement the related parts in UserProfileOverlay but wanted to create the PR first to make sure whether I'm even on the right path with this then look into that one later. Especially since I'm not sure how the block button should be added there.
On the website, it's inside a separate menu but that menu isn't there in-game yet, and just adding a block button with a circled X icon probably wouldn't be clear enough. Also, adding text to the button would make it stick out compared to its neighboring ones. But maybe that's fine for now as it's better than not having a block button at all?

Edit: Marked as draft since I need to know which direction to take for the user profile overlay.

@zihadmahiuddin
Copy link
Contributor Author

Actually, maybe it'll be better to do the user profile stuff in a separate PR.

@zihadmahiuddin zihadmahiuddin marked this pull request as ready for review March 28, 2025 06:38
@zihadmahiuddin
Copy link
Contributor Author

zihadmahiuddin commented Mar 28, 2025

There is a little problem in the tests here.
It expects a single LoadingSpinner but now UserPanel also has one, so that fails.

This diff fixes the tests, but I'm not sure if this is the right way to do it.

diff --git a/osu.Game.Tests/Visual/Online/TestSceneFriendDisplay.cs b/osu.Game.Tests/Visual/Online/TestSceneFriendDisplay.cs
index 25611cf8d5..52905fe5da 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneFriendDisplay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneFriendDisplay.cs
@@ -218,7 +218,7 @@ public void TestLoadFriendsBeforeDisplay()
         }
 
         private void waitForLoad()
-            => AddUntilStep("wait for panels to load", () => this.ChildrenOfType<LoadingSpinner>().Single().State.Value, () => Is.EqualTo(Visibility.Hidden));
+            => AddUntilStep("wait for panels to load", () => this.ChildrenOfType<LoadingSpinner>().First().State.Value, () => Is.EqualTo(Visibility.Hidden));
 
         private void assertVisiblePanelCount<T>(int expectedVisible)
             where T : UserPanel

@bdach bdach self-requested a review March 28, 2025 09:19
Copy link
Collaborator

@bdach bdach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not feeling too happy with any of this

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not feel great at all about IAPIProvider sprawling out to include block information like this. To me LocalUser, Friends, and Blocks should probably go live elsewhere at this point (and I am aware the implications the first one especially has on everything). I'm not sure I've ever expressed this out loud but it has struck me as odd for a while that IAPIProvider just has a friends list on it.

Not sure this is going to get done because of these implications but I feel like I need to at least voice concern. It shouldn't be IAPIProvider's job to contain all this state imo. At least not the friends/blocks stuff. Especially given that we also have yet-to-be-fixed issues like the friends list only updating on launch and when friending someone, so you can open client, then web, then friend someone on web and the client will be blissfully unaware until a reboot, so we'll probably want extra tracking, which will probably bloat IAPIProvider even more etc....

foreach (APIRelation block in e.NewItems.Cast<APIRelation>())
{
int userId = block.TargetID;
removeUserPanel(userId);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that should even be handled client-side at all like this? I'd say no, and based on ppy/osu-server-spectator#264 I'd say I'm not alone in thinking that.

@bdach bdach requested review from peppy and smoogipoo March 28, 2025 09:32
Now that `UserPanel` also has a `LoadingSpinner`, we need to use `.First` instead of `.Single` here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement blocking users
2 participants