Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
Support opening of profile links
Browse files Browse the repository at this point in the history
  • Loading branch information
bleakgrey committed Apr 28, 2018
1 parent 52d34f5 commit c5539c6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/Views/AccountView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,25 @@ public class Tootle.AccountView : Tootle.HomeView {
});
}

public static void open_from_name (string name){
var url = "%s/api/v1/accounts/search?limit=1&q=%s".printf (Tootle.settings.instance_url, name);
var msg = new Soup.Message("GET", url);
Tootle.network.queue(msg, (sess, mess) => {
try{
var node = Tootle.network.parse_array (mess).get_element (0);
var object = node.get_object ();
if (object != null){
var acc = Account.parse(object);
Tootle.window.open_secondary_view (new AccountView (acc));
}
else
warning ("No results found for account: "+name); //TODO: toast notifications
}
catch (GLib.Error e) {
warning ("Can't update feed");
warning (e.message);
}
});
}

}
2 changes: 1 addition & 1 deletion src/Widgets/RichLabel.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Tootle.RichLabel : Gtk.Label {

if ("/@" in url){
var profile = url.split("/@")[1];
//TODO: search profiles
AccountView.open_from_name (profile);
return true;
}

Expand Down

0 comments on commit c5539c6

Please sign in to comment.