fix: refresh git branch status on project switch
This commit is contained in:
		
							parent
							
								
									73d118dcee
								
							
						
					
					
						commit
						a734a008e1
					
				
					 1 changed files with 13 additions and 2 deletions
				
			
		| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue