fix: refresh git branch status on project switch

This commit is contained in:
CJ van den Berg 2025-07-29 10:12:15 +02:00
parent 73d118dcee
commit a734a008e1
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -44,6 +44,7 @@ pub fn create(
.on_click = on_click,
.on_layout = layout,
.on_render = render,
.on_receive = receive,
.on_event = event_handler,
});
}
@ -60,11 +61,21 @@ pub fn ctx_deinit(self: *Self) void {
if (self.behind) |p| self.allocator.free(p);
}
fn on_click(_: *Self, _: *Button.State(Self)) void {
git.status(0) catch {};
fn on_click(self: *Self, _: *Button.State(Self)) void {
self.refresh_git_status();
command.executeName("show_git_status", .{}) catch {};
}
fn refresh_git_status(_: *Self) void {
git.status(0) catch {};
}
pub fn receive(self: *Self, _: *Button.State(Self), _: tp.pid_ref, m: tp.message) error{Exit}!bool {
if (try m.match(.{ "PRJ", "open" }))
self.refresh_git_status();
return false;
}
fn receive_git(self: *Self, _: tp.pid_ref, m: tp.message) MessageFilter.Error!bool {
return if (try match(m.buf, .{ "git", more }))
self.process_git(m)