Skip to content

Commit

Permalink
feat(Thread): refresh root status on load (#1266)
Browse files Browse the repository at this point in the history
  • Loading branch information
GeopJr authored Dec 14, 2024
1 parent 30c822f commit aaecef0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/Views/Thread.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,33 @@ public class Tuba.Views.Thread : Views.ContentBase, AccountHolder {
allow_nesting: true
);
construct_account_holder ();
update_root_status (status.id);
}
~Thread () {
debug ("Destroying Thread");
destruct_account_holder ();
}

private void update_root_status (string status_id = root_status.id) {
if (root_status == null) return;

new Request.GET (@"/api/v1/statuses/$status_id")
.with_account (account)
.with_ctx (this)
.then ((in_stream) => {
var parser = Network.get_parser_from_inputstream (in_stream);
var node = network.parse_node (parser);
var api_status = API.Status.from (node);
if (api_status != null) {
if (root_status != null) root_status.patch (api_status);
if (root_status_widget != null) {
root_status_widget.on_edit (api_status);
}
}
})
.exec ();
}

public override void on_account_changed (InstanceAccount? acc) {
account = acc;
GLib.Idle.add (request);
Expand Down
2 changes: 1 addition & 1 deletion src/Widgets/Status.vala
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@
app.main_window.open_view (new Views.StatusStats (status.formal.id, has_reactions ()));
}

private void on_edit (API.Status x) {
public void on_edit (API.Status x) {
this.status.patch (x);
bind ();
}
Expand Down

0 comments on commit aaecef0

Please sign in to comment.