experiment: requests v2#1643
Conversation
| } | ||
|
|
||
| public async bool exec (out GLib.InputStream in_stream, out Soup.MessageHeaders response_headers) throws GLib.Error, Oopsie { | ||
| if (this.cancellable != null && !this.cancellable.is_cancelled ()) this.cancellable.cancel (); |
There was a problem hiding this comment.
| if (this.cancellable != null && !this.cancellable.is_cancelled ()) this.cancellable.cancel (); | |
| this.cancellable?.cancel (); |
GLib.Cancellable.cancel () already performs the already-cancelled check.
- async error parsing - remove useless cancelled branch - bool => void return type - handle cancelled properly
|
Thanks for the review! Maybe the API should change again and return the inputstream instead of outing it, now that we don't need to return bool |
|
Yeah that makes sense too. |
|
Moving forward with replacing all instances, something that caught my attention is vala's construction order: // Home.vala, moving the refreshing away from idle and to just the async function
construct {
url = "/api/v1/timelines/home";
label = _("Home");
icon = "tuba-user-home-symbolic";fails with url == null but public Home () {
Object (
url: "/api/v1/timelines/home",
label: _("Home")
);
}works. At the same, the Notifications.vala url depends on the account, which is not available during 🤔 Personally, I'd expect construct to run before using the Object at all. I know I'm wrong now, but I thought it was like this: construct -> Home () -> Object () |
|
More annoyances: public Views.ContentBase add_timeline_tab (string label, string icon, string url, Type accepts, string? empty_state_title = null, string? empty_state_icon = null) {
var tab = new Views.Accounts () {
url = url,
label = label,
icon = icon,
accepts = accepts
};url == null, but introducing this works: public class Tuba.Views.Accounts : Views.Timeline {
public Accounts.prefilled (string url, string label, string icon) {
Object (
url: url,
label: label,
icon: icon
);
} |
|
On top of GObject's already complicated construction/initialization flow, Vala adds its own layer of confusion 😭 I hate everything about the way it's done, and it's unlikely that I could change much here about Vala semantics (especially given the state of Vala maintenance, which makes it hard to get any non-trivial change merged into Vala). You would think Properties whose values are visible at
What you mean about From the GObject standpoint, the right thing to do is:
Here's a piece of code for you to play with: #! /usr/bin/vala
public class Base : Object {
public int some_prop {
set { print ("Setting some_prop to %d\n", value); }
}
public int some_construct_prop {
construct set { print ("Setting some_construct_prop to %d\n", value); }
}
public Base () {
print ("Base: before chain-up\n");
Object (some_prop: 42);
print ("Base: after chain-up\n");
}
construct {
print ("Base: construct block\n");
}
}
public class Derived : Base {
public Derived () {
print ("Derived: before chain-up\n");
base ();
print ("Derived: after chain-up\n");
}
construct {
print ("Derived: constrct block\n");
}
}
void main () {
new Derived ();
}I get: |
Timeline.vala inherits from AccountHolder which when constructed refreshes the timeline (initial fetch), and that's where url is null. Prior to changing everything to the async one, it would do the request in idle_add (also why we don't come across it in the current state of this PR) and 🤞 we were lucky it finished after the constructions. But now it seems that running the async request directly is faster. (FWIW, url is
That sounds good, but currently it's more tied to the account (so changing accounts refreshes the timelines as the new account) and there's also other things in some timelines (from pagination to filters and api versions; that might not need immediate fetching). I'll see if I can do it without breaking too many things.
I think I'll go with this. Right now, I've been literally just moving them to: public Home () {
Object (
url: "/api/v1/timelines/home",
label: _("Home")
);
}
as suspected, I really did think it was
I read that, and honestly, what happens next depends on Rico who hasn't really acknowledged it as far as I can tell. Outside of GNOME/Elementary, maybe the Frida / NowSecure people would be interested in moving Vala forward? (since it's written in Vala) Speaking of Elementary, they use lambdas a lot... https://github.com/search?q=org%3Aelementary%20%3D%3E&type=code one can only imagine the memory benefits they could get by getting those ref loops fixed |
sup: #1481
fix: #1480