diff --git a/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs b/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs
index a8ed2cf110..ce8136199f 100644
--- a/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs
+++ b/osu.Game.Tests/Visual/Online/TestSceneUserProfileOverlay.cs
@@ -71,13 +71,13 @@ namespace osu.Game.Tests.Visual.Online
{
base.LoadComplete();
- AddStep("Show offline dummy", () => profile.ShowUser(TEST_USER, false));
+ AddStep("Show offline dummy", () => profile.ShowUser(TEST_USER));
AddStep("Show null dummy", () => profile.ShowUser(new APIUser
{
Username = @"Null",
Id = 1,
- }, false));
+ }));
AddStep("Show ppy", () => profile.ShowUser(new APIUser
{
@@ -86,7 +86,7 @@ namespace osu.Game.Tests.Visual.Online
IsSupporter = true,
Country = new Country { FullName = @"Australia", FlagName = @"AU" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
- }, api.IsLoggedIn));
+ }));
AddStep("Show flyte", () => profile.ShowUser(new APIUser
{
@@ -94,7 +94,7 @@ namespace osu.Game.Tests.Visual.Online
Id = 3103765,
Country = new Country { FullName = @"Japan", FlagName = @"JP" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
- }, api.IsLoggedIn));
+ }));
AddStep("Show bancho", () => profile.ShowUser(new APIUser
{
@@ -103,10 +103,10 @@ namespace osu.Game.Tests.Visual.Online
IsBot = true,
Country = new Country { FullName = @"Saint Helena", FlagName = @"SH" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c4.jpg"
- }, api.IsLoggedIn));
+ }));
- AddStep("Show ppy from username", () => profile.ShowUser(@"peppy"));
- AddStep("Show flyte from username", () => profile.ShowUser(@"flyte"));
+ AddStep("Show ppy from username", () => profile.ShowUser(new APIUser { Username = @"peppy" }));
+ AddStep("Show flyte from username", () => profile.ShowUser(new APIUser { Username = @"flyte" }));
AddStep("Hide", profile.Hide);
AddStep("Show without reload", profile.Show);
diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs
index a7ed7fedf5..ea8682e696 100644
--- a/osu.Game/OsuGame.cs
+++ b/osu.Game/OsuGame.cs
@@ -53,8 +53,10 @@ using osu.Game.Database;
using osu.Game.Extensions;
using osu.Game.IO;
using osu.Game.Localisation;
+using osu.Game.Online.API.Requests.Responses;
using osu.Game.Performance;
using osu.Game.Skinning.Editor;
+using osu.Game.Users;
namespace osu.Game
{
@@ -323,10 +325,9 @@ namespace osu.Game
break;
case LinkAction.OpenUserProfile:
- if (int.TryParse(link.Argument, out int userId))
- ShowUser(userId);
- else
- ShowUser(link.Argument);
+ ShowUser(int.TryParse(link.Argument, out int userId)
+ ? new APIUser { Id = userId }
+ : new APIUser { Username = link.Argument });
break;
@@ -383,14 +384,8 @@ namespace osu.Game
///
/// Show a user's profile as an overlay.
///
- /// The user to display.
- public void ShowUser(int userId) => waitForReady(() => userProfile, _ => userProfile.ShowUser(userId));
-
- ///
- /// Show a user's profile as an overlay.
- ///
- /// The user to display.
- public void ShowUser(string username) => waitForReady(() => userProfile, _ => userProfile.ShowUser(username));
+ /// The user to display.
+ public void ShowUser(IUser user) => waitForReady(() => userProfile, _ => userProfile.ShowUser(user));
///
/// Show a beatmap's set as an overlay, displaying the given beatmap.
diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs
index d9b4e68a75..9fac1463f2 100644
--- a/osu.Game/Overlays/UserProfileOverlay.cs
+++ b/osu.Game/Overlays/UserProfileOverlay.cs
@@ -14,6 +14,7 @@ using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays.Profile;
using osu.Game.Overlays.Profile.Sections;
+using osu.Game.Users;
using osuTK;
using osuTK.Graphics;
@@ -38,18 +39,14 @@ namespace osu.Game.Overlays
protected override Color4 BackgroundColour => ColourProvider.Background6;
- public void ShowUser(int userId) => ShowUser(new APIUser { Id = userId });
-
- public void ShowUser(string username) => ShowUser(new APIUser { Username = username });
-
- public void ShowUser(APIUser user, bool fetchOnline = true)
+ public void ShowUser(IUser user)
{
if (user == APIUser.SYSTEM_USER)
return;
Show();
- if (user.Id == Header?.User.Value?.Id)
+ if (user.OnlineID == Header?.User.Value?.Id)
return;
if (sectionsContainer != null)
@@ -116,19 +113,20 @@ namespace osu.Game.Overlays
}
};
- if (fetchOnline)
- {
- userReq = user.Id > 1 ? new GetUserRequest(user.Id) : new GetUserRequest(user.Username);
- userReq.Success += userLoadComplete;
- API.Queue(userReq);
- }
- else
+ sectionsContainer.ScrollToTop();
+
+ // Check arbitrarily whether this user has already been populated.
+ // This is only generally used by tests, but should be quite safe unless we want to force a refresh on loading a previous user in the future.
+ if (user is APIUser apiUser && apiUser.JoinDate != default)
{
userReq = null;
- userLoadComplete(user);
+ userLoadComplete(apiUser);
+ return;
}
- sectionsContainer.ScrollToTop();
+ userReq = user.OnlineID > 1 ? new GetUserRequest(user.OnlineID) : new GetUserRequest(user.Username);
+ userReq.Success += userLoadComplete;
+ API.Queue(userReq);
}
private void userLoadComplete(APIUser user)
diff --git a/osu.Game/Users/Drawables/ClickableAvatar.cs b/osu.Game/Users/Drawables/ClickableAvatar.cs
index 6883cc0e62..2825c41ef6 100644
--- a/osu.Game/Users/Drawables/ClickableAvatar.cs
+++ b/osu.Game/Users/Drawables/ClickableAvatar.cs
@@ -66,7 +66,7 @@ namespace osu.Game.Users.Drawables
private void openProfile()
{
if (user?.Id > 1)
- game?.ShowUser(user.Id);
+ game?.ShowUser(user);
}
private class ClickableArea : OsuClickableContainer