From 75fdca928e9d19ae12e2a8ce739cc9af42fda20b Mon Sep 17 00:00:00 2001 From: naoey Date: Mon, 26 Feb 2018 00:58:20 +0530 Subject: [PATCH] Handle links correctly and don't re-open profile if the user is same. --- osu.Game/Online/Chat/MessageFormatter.cs | 4 ++-- .../Profile/Sections/Recent/DrawableRecentActivity.cs | 8 ++++---- osu.Game/Overlays/UserProfileOverlay.cs | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/osu.Game/Online/Chat/MessageFormatter.cs b/osu.Game/Online/Chat/MessageFormatter.cs index 3fdce3ec12..9966f78435 100644 --- a/osu.Game/Online/Chat/MessageFormatter.cs +++ b/osu.Game/Online/Chat/MessageFormatter.cs @@ -210,13 +210,13 @@ namespace osu.Game.Online.Chat return inputMessage; } - public static List GetLinks(string text) + public static MessageFormatterResult FormatText(string text) { var result = format(text); result.Links.Sort(); - return result.Links; + return result; } public class MessageFormatterResult diff --git a/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs b/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs index 6abf68e3e9..4d215467bb 100644 --- a/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs +++ b/osu.Game/Overlays/Profile/Sections/Recent/DrawableRecentActivity.cs @@ -34,8 +34,8 @@ namespace osu.Game.Overlays.Profile.Sections.Recent this.activity = activity; this.user = user; - userLinkTemplate = $"[{activity.User?.Username}]({urlToAbsolute(activity.User?.Url)})"; - beatmapLinkTemplate = $"[{activity.Beatmap?.Title}]({urlToAbsolute(activity.Beatmap?.Url)})"; + userLinkTemplate = $"[{urlToAbsolute(activity.User?.Url)} {activity.User?.Username}]"; + beatmapLinkTemplate = $"[{urlToAbsolute(activity.Beatmap?.Url)} {activity.Beatmap?.Title}]"; } [BackgroundDependencyLoader] @@ -59,9 +59,9 @@ namespace osu.Game.Overlays.Profile.Sections.Recent Colour = OsuColour.Gray(0xAA), }); - string text = activityToString(); + var formatted = MessageFormatter.FormatText(activityToString()); - content.AddLinks(text, MessageFormatter.GetLinks(text)); + content.AddLinks(formatted.Text, formatted.Links); } protected override Drawable CreateLeftVisual() diff --git a/osu.Game/Overlays/UserProfileOverlay.cs b/osu.Game/Overlays/UserProfileOverlay.cs index 39cb71ea27..f19fc4062c 100644 --- a/osu.Game/Overlays/UserProfileOverlay.cs +++ b/osu.Game/Overlays/UserProfileOverlay.cs @@ -75,6 +75,9 @@ namespace osu.Game.Overlays public void ShowUser(long userId) { + if (userId == Header.User.Id) + return; + ShowUser(new User { Id = userId }, true); }