Remove old try/catch blocks
This commit is contained in:
parent
130f8e3e51
commit
58730814dc
|
@ -49,33 +49,26 @@ public class Tootle.Views.ExpandedStatus : Views.Abstract {
|
||||||
var url = "%s/api/v1/statuses/%lld/context".printf (accounts.formal.instance, root_status.id);
|
var url = "%s/api/v1/statuses/%lld/context".printf (accounts.formal.instance, root_status.id);
|
||||||
var msg = new Soup.Message ("GET", url);
|
var msg = new Soup.Message ("GET", url);
|
||||||
network.queue (msg, (sess, mess) => {
|
network.queue (msg, (sess, mess) => {
|
||||||
try{
|
var root = network.parse (mess);
|
||||||
var root = network.parse (mess);
|
var ancestors = root.get_array_member ("ancestors");
|
||||||
|
ancestors.foreach_element ((array, i, node) => {
|
||||||
|
var object = node.get_object ();
|
||||||
|
if (object != null) {
|
||||||
|
var status = API.Status.parse (object);
|
||||||
|
prepend (status);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
var ancestors = root.get_array_member ("ancestors");
|
prepend (root_status, true);
|
||||||
ancestors.foreach_element ((array, i, node) => {
|
|
||||||
var object = node.get_object ();
|
|
||||||
if (object != null) {
|
|
||||||
var status = API.Status.parse (object);
|
|
||||||
prepend (status);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
prepend (root_status, true);
|
var descendants = root.get_array_member ("descendants");
|
||||||
|
descendants.foreach_element ((array, i, node) => {
|
||||||
var descendants = root.get_array_member ("descendants");
|
var object = node.get_object ();
|
||||||
descendants.foreach_element ((array, i, node) => {
|
if (object != null) {
|
||||||
var object = node.get_object ();
|
var status = API.Status.parse (object);
|
||||||
if (object != null) {
|
prepend (status);
|
||||||
var status = API.Status.parse (object);
|
}
|
||||||
prepend (status);
|
});
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
catch (GLib.Error e) {
|
|
||||||
warning ("Can't get context for a status");
|
|
||||||
warning (e.message);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
@ -85,20 +78,15 @@ public class Tootle.Views.ExpandedStatus : Views.Abstract {
|
||||||
var msg = new Soup.Message ("GET", url);
|
var msg = new Soup.Message ("GET", url);
|
||||||
msg.priority = Soup.MessagePriority.HIGH;
|
msg.priority = Soup.MessagePriority.HIGH;
|
||||||
network.queue (msg, (sess, mess) => {
|
network.queue (msg, (sess, mess) => {
|
||||||
try {
|
var root = network.parse (mess);
|
||||||
var root = network.parse (mess);
|
var statuses = root.get_array_member ("statuses");
|
||||||
var statuses = root.get_array_member ("statuses");
|
var object = statuses.get_element (0).get_object ();
|
||||||
var object = statuses.get_element (0).get_object ();
|
if (object != null){
|
||||||
if (object != null){
|
var st = API.Status.parse (object);
|
||||||
var st = API.Status.parse (object);
|
window.open_view (new Views.ExpandedStatus (st));
|
||||||
window.open_view (new Views.ExpandedStatus (st));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Desktop.open_uri (q);
|
|
||||||
}
|
|
||||||
catch (GLib.Error e) {
|
|
||||||
warning (e.message);
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Desktop.open_uri (q);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,36 +242,11 @@ public class Tootle.Views.Profile : Views.Timeline {
|
||||||
var msg = new Soup.Message ("GET", url);
|
var msg = new Soup.Message ("GET", url);
|
||||||
msg.priority = Soup.MessagePriority.HIGH;
|
msg.priority = Soup.MessagePriority.HIGH;
|
||||||
network.queue (msg, (sess, mess) => {
|
network.queue (msg, (sess, mess) => {
|
||||||
try {
|
var root = network.parse (mess);
|
||||||
var root = network.parse (mess);
|
var acc = API.Account.parse (root);
|
||||||
var acc = API.Account.parse (root);
|
window.open_view (new Views.Profile (acc));
|
||||||
window.open_view (new Views.Profile (acc));
|
}, (status, reason) => {
|
||||||
}
|
network.on_error (status, reason);
|
||||||
catch (GLib.Error e) {
|
|
||||||
warning ("Can't find account");
|
|
||||||
warning (e.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void open_from_name (string name){
|
|
||||||
var url = "%s/api/v1/accounts/search?limit=1&q=%s".printf (accounts.formal.instance, name);
|
|
||||||
var msg = new Soup.Message("GET", url);
|
|
||||||
msg.priority = Soup.MessagePriority.HIGH;
|
|
||||||
network.queue (msg, (sess, mess) => {
|
|
||||||
try {
|
|
||||||
var node = network.parse_array (mess).get_element (0);
|
|
||||||
var object = node.get_object ();
|
|
||||||
if (object != null){
|
|
||||||
var acc = API.Account.parse (object);
|
|
||||||
window.open_view (new Views.Profile (acc));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
app.toast (_("User not found"));
|
|
||||||
}
|
|
||||||
catch (GLib.Error e) {
|
|
||||||
warning (e.message);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public class Tootle.Widgets.RichLabel : Label {
|
||||||
|
|
||||||
if ("@" in url || "tags" in url) {
|
if ("@" in url || "tags" in url) {
|
||||||
var query = Soup.URI.encode (url, null);
|
var query = Soup.URI.encode (url, null);
|
||||||
var msg_url = "%s/api/v1/search?q=%s".printf (accounts.formal.instance, query);
|
var msg_url = "%s/api/v1/search?q=%s&resolve=true".printf (accounts.formal.instance, query);
|
||||||
var msg = new Soup.Message("GET", msg_url);
|
var msg = new Soup.Message("GET", msg_url);
|
||||||
msg.priority = Soup.MessagePriority.HIGH;
|
msg.priority = Soup.MessagePriority.HIGH;
|
||||||
network.inject (msg, Network.INJECT_TOKEN);
|
network.inject (msg, Network.INJECT_TOKEN);
|
||||||
|
|
Loading…
Reference in New Issue