public void ShowUser(User user, bool fetchOnline = true) { if (user == User.SYSTEM_USER) { return; } Show(); if (user.Id == Header?.User.Value?.Id) { return; } userReq?.Cancel(); Clear(); lastSection = null; sections = !user.IsBot ? new ProfileSection[] { //new AboutSection(), new RecentSection(), new RanksSection(), //new MedalsSection(), new HistoricalSection(), new BeatmapsSection(), new KudosuSection() } : Array.Empty <ProfileSection>(); tabs = new ProfileTabControl { RelativeSizeAxes = Axes.X, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Height = 30 }; Add(new Box { RelativeSizeAxes = Axes.Both, Colour = OsuColour.Gray(0.1f) }); Add(sectionsContainer = new ProfileSectionsContainer { ExpandableHeader = Header = new ProfileHeader(), FixedHeader = tabs, HeaderBackground = new Box { Colour = OsuColour.Gray(34), RelativeSizeAxes = Axes.Both }, }); sectionsContainer.SelectedSection.ValueChanged += section => { if (lastSection != section.NewValue) { lastSection = section.NewValue; tabs.Current.Value = lastSection; } }; tabs.Current.ValueChanged += section => { if (lastSection == null) { lastSection = sectionsContainer.Children.FirstOrDefault(); if (lastSection != null) { tabs.Current.Value = lastSection; } return; } if (lastSection != section.NewValue) { lastSection = section.NewValue; sectionsContainer.ScrollTo(lastSection); } }; if (fetchOnline) { userReq = new GetUserRequest(user.Id); userReq.Success += userLoadComplete; API.Queue(userReq); } else { userReq = null; userLoadComplete(user); } sectionsContainer.ScrollToTop(); }
public void ShowUser(IUser user) { if (user.OnlineID == APIUser.SYSTEM_USER_ID) { return; } Show(); if (user.OnlineID == Header?.User.Value?.Id) { return; } if (sectionsContainer != null) { sectionsContainer.ExpandableHeader = null; } userReq?.Cancel(); Clear(); lastSection = null; sections = !user.IsBot ? new ProfileSection[] { //new AboutSection(), new RecentSection(), new RanksSection(), //new MedalsSection(), new HistoricalSection(), new BeatmapsSection(), new KudosuSection() } : Array.Empty <ProfileSection>(); tabs = new ProfileSectionTabControl { RelativeSizeAxes = Axes.X, Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, }; Add(sectionsContainer = new ProfileSectionsContainer { ExpandableHeader = Header, FixedHeader = tabs, HeaderBackground = new Box { // this is only visible as the ProfileTabControl background Colour = ColourProvider.Background5, RelativeSizeAxes = Axes.Both }, }); sectionsContainer.SelectedSection.ValueChanged += section => { if (lastSection != section.NewValue) { lastSection = section.NewValue; tabs.Current.Value = lastSection; } }; tabs.Current.ValueChanged += section => { if (lastSection == null) { lastSection = sectionsContainer.Children.FirstOrDefault(); if (lastSection != null) { tabs.Current.Value = lastSection; } return; } if (lastSection != section.NewValue) { lastSection = section.NewValue; sectionsContainer.ScrollTo(lastSection); } }; 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(apiUser); return; } userReq = user.OnlineID > 1 ? new GetUserRequest(user.OnlineID) : new GetUserRequest(user.Username); userReq.Success += userLoadComplete; API.Queue(userReq); }