Remove weird fetchOnline logic

This commit is contained in:
Dean Herbert 2021-11-05 13:52:42 +09:00
parent 1f5ca122b0
commit ba74dd93b2
2 changed files with 18 additions and 17 deletions

View File

@ -71,13 +71,13 @@ namespace osu.Game.Tests.Visual.Online
{ {
base.LoadComplete(); 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 AddStep("Show null dummy", () => profile.ShowUser(new APIUser
{ {
Username = @"Null", Username = @"Null",
Id = 1, Id = 1,
}, false)); }));
AddStep("Show ppy", () => profile.ShowUser(new APIUser AddStep("Show ppy", () => profile.ShowUser(new APIUser
{ {
@ -86,7 +86,7 @@ namespace osu.Game.Tests.Visual.Online
IsSupporter = true, IsSupporter = true,
Country = new Country { FullName = @"Australia", FlagName = @"AU" }, Country = new Country { FullName = @"Australia", FlagName = @"AU" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg" CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c3.jpg"
}, api.IsLoggedIn)); }));
AddStep("Show flyte", () => profile.ShowUser(new APIUser AddStep("Show flyte", () => profile.ShowUser(new APIUser
{ {
@ -94,7 +94,7 @@ namespace osu.Game.Tests.Visual.Online
Id = 3103765, Id = 3103765,
Country = new Country { FullName = @"Japan", FlagName = @"JP" }, Country = new Country { FullName = @"Japan", FlagName = @"JP" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg" CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c6.jpg"
}, api.IsLoggedIn)); }));
AddStep("Show bancho", () => profile.ShowUser(new APIUser AddStep("Show bancho", () => profile.ShowUser(new APIUser
{ {
@ -103,10 +103,10 @@ namespace osu.Game.Tests.Visual.Online
IsBot = true, IsBot = true,
Country = new Country { FullName = @"Saint Helena", FlagName = @"SH" }, Country = new Country { FullName = @"Saint Helena", FlagName = @"SH" },
CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c4.jpg" CoverUrl = @"https://osu.ppy.sh/images/headers/profile-covers/c4.jpg"
}, api.IsLoggedIn)); }));
AddStep("Show ppy from username", () => profile.ShowUser(@"peppy")); AddStep("Show ppy from username", () => profile.ShowUser(new APIUser { Username = @"peppy" }));
AddStep("Show flyte from username", () => profile.ShowUser(@"flyte")); AddStep("Show flyte from username", () => profile.ShowUser(new APIUser { Username = @"flyte" }));
AddStep("Hide", profile.Hide); AddStep("Hide", profile.Hide);
AddStep("Show without reload", profile.Show); AddStep("Show without reload", profile.Show);

View File

@ -42,7 +42,7 @@ namespace osu.Game.Overlays
public void ShowUser(string username) => ShowUser(new APIUser { Username = username }); 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) if (user == APIUser.SYSTEM_USER)
return; return;
@ -116,19 +116,20 @@ namespace osu.Game.Overlays
} }
}; };
if (fetchOnline) sectionsContainer.ScrollToTop();
{
userReq = user.Id > 1 ? new GetUserRequest(user.Id) : new GetUserRequest(user.Username); // Check arbitrarily whether this user has already been populated.
userReq.Success += userLoadComplete; // 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.
API.Queue(userReq); if (user is APIUser apiUser && apiUser.JoinDate != default)
}
else
{ {
userReq = null; 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) private void userLoadComplete(APIUser user)