From e2e3400c86c1a49c30d708f7327acd5d14d0fde1 Mon Sep 17 00:00:00 2001 From: Bleak Grey Date: Sat, 1 Aug 2020 19:47:49 +0300 Subject: [PATCH] Fix links opening twice --- src/Widgets/RichLabel.vala | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/Widgets/RichLabel.vala b/src/Widgets/RichLabel.vala index 8650411..75f9512 100644 --- a/src/Widgets/RichLabel.vala +++ b/src/Widgets/RichLabel.vala @@ -21,7 +21,6 @@ public class Tootle.Widgets.RichLabel : Label { justify = Justification.LEFT; single_line_mode = false; set_line_wrap (true); - activate_link.connect (open_link); } public RichLabel (string text) { @@ -43,10 +42,7 @@ public class Tootle.Widgets.RichLabel : Label { .replace (""", "\""); } - public bool open_link (string url) { - if ("tootle://" in url) - return false; - + public override bool activate_link (string url) { if (mentions != null){ mentions.@foreach (mention => { if (url == mention.url) @@ -63,23 +59,20 @@ public class Tootle.Widgets.RichLabel : Label { } var resolve = "@" in url; - var resolved = false; - if (resolve) { + if (!resolve) + Desktop.open_uri (url); + else { accounts.active.resolve.begin (url, (obj, res) => { try { accounts.active.resolve.end (res).open (); - resolved = true; } catch (Error e) { warning (@"Failed to resolve URL \"$url\":"); warning (e.message); + Desktop.open_uri (url); } }); } - - if (!resolved) - Desktop.open_uri (url); - return true; }