-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add the ability to add/remove friends in UserProfileHeader
#30467
Conversation
UserProfileHeader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
superficial review, just the most obvious problems
[JsonProperty("target")] | ||
public APIUser? TargetUser { get; set; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is this field referenced from? It's not in https://github.com/nanaya/osu-web/blob/c029567dce89fd68446f56e40870c3cec01d7591/resources/js/interfaces/user-relation-json.ts#L4-L8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But he does exist, I think it's this is in
https://github.com/nanaya/osu-web/blob/fe21e207e8f8106ae024d8eab9108b8481ea1b5a/app/Http/Controllers/FriendsController.php#L57
api will return APIUser when request friends but not for block relation
{ | ||
followerCount += status.Value == FriendStatus.None ? 1 : -1; | ||
|
||
api.UpdateLocalFriends(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this really need to refetch friends every time? The request just succeeded, you can tell what happened, why do a refetch?
I guess it would make sense in the case of adding users, because you might not have the APIUser
instance present or whatever, but isn't/can't that be in the add friend request or response? Or even couldn't the APIUser
be taken from the ambient overlay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried removing the refetch but things crash, something or other about groups not being populated in the response of this.
@ppy/team-client can I get a second pair of eyes on this to make sure you're ok with it?
/// <summary> | ||
/// Update the friends status of the current user. | ||
/// </summary> | ||
void UpdateLocalFriends(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to preceding comment - if the need to refetch users can be removed, this method probably doesn't need to exist. (I guess there is #13604, but it's (a) out of scope here, and (b) not even a given that a poll like the OP of that proposes is the right thing to do.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll keep him for now until the results come in?
I have fixed some of the issues that I think are now fixable, and now we cannot update friends list in real time |
I'm not sure what you're trying to say? You haven't undone any of the |
UpdateLocalFriends() will only be called when adding or deleting friends or logging in. |
As I said, that's out of scope of this PR. Let's focus on the adding/removing of friends here. |
UserProfileHeader
UserProfileHeader
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems fine
@@ -6,7 +6,7 @@ | |||
|
|||
namespace osu.Game.Online.API.Requests | |||
{ | |||
public class GetFriendsRequest : APIRequest<List<APIUser>> | |||
public class GetFriendsRequest : APIRequest<List<APIRelation>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this works because API-side the format of the response is changed and is dependent on x-api-version
. This means that at least this single change to this single file must go out before the next release, or the friends displays will be broken. (Discovered in testing with #30499.)
I've adjusted the slightly because the transition of the button states was irking me. Before: After: Now, rather than the full state change being delayed, only the mutual status is. I think this makes more sense. @bdach please double check you're okay with this. |
for adding friend we can get a not sure whether to do this or not. |
Hmm, I've tried that but |
ok I got it, response is {
"user_relation": {
"target_id": 960,
"relation_type": "friend",
"mutual": true
}
} The actual data is in the inner layer my bad |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems fine. the issue with the wrong request shape is probably why i couldn't get this to work without refetching friends, but i don't have the mental energy to try it again
what this pr do:
APIRelation
, it's also used in "blocking relationships"UpdateLocalFriends
toIAPIProvider
for update friends list manually, because it is currently impossible to get the friend list in real time through push method.ProfileHeaderButton
for display the online request status.need to be mentioned:
FollowersButton
when profile user loaded, and data changes are handled locally, because it is not possible to update user in profileOverlay after performing an operation