fix status_tree not showing while first status loading

This commit is contained in:
extrawurst 2022-11-21 14:45:03 +01:00
parent 3667db37e1
commit 3fee481e8d
3 changed files with 23 additions and 0 deletions

View file

@ -320,7 +320,21 @@ impl Component for ChangesComponent {
fn focused(&self) -> bool { fn focused(&self) -> bool {
self.files.focused() self.files.focused()
} }
fn focus(&mut self, focus: bool) { fn focus(&mut self, focus: bool) {
self.files.focus(focus); self.files.focus(focus);
} }
fn is_visible(&self) -> bool {
self.files.is_visible()
}
fn hide(&mut self) {
self.files.hide();
}
fn show(&mut self) -> Result<()> {
self.files.show()?;
Ok(())
}
} }

View file

@ -70,6 +70,7 @@ impl StatusTreeComponent {
/// ///
pub fn update(&mut self, list: &[StatusItem]) -> Result<()> { pub fn update(&mut self, list: &[StatusItem]) -> Result<()> {
self.pending = false; self.pending = false;
let new_hash = hash(list); let new_hash = hash(list);
if self.current_hash != new_hash { if self.current_hash != new_hash {
self.tree.update(list)?; self.tree.update(list)?;
@ -373,6 +374,7 @@ impl DrawableComponent for StatusTreeComponent {
) )
}) })
.skip(self.scroll_top.get()); .skip(self.scroll_top.get());
ui::draw_list( ui::draw_list(
f, f,
r, r,

View file

@ -427,6 +427,7 @@ impl Status {
} }
fn check_remotes(&mut self) { fn check_remotes(&mut self) {
//TODO: make get_branches_info async
self.has_remotes = self.has_remotes =
sync::get_branches_info(&self.repo.borrow(), false) sync::get_branches_info(&self.repo.borrow(), false)
.map(|branches| !branches.is_empty()) .map(|branches| !branches.is_empty())
@ -965,10 +966,16 @@ impl Component for Status {
fn hide(&mut self) { fn hide(&mut self) {
self.visible = false; self.visible = false;
self.index.hide();
self.index_wd.hide();
} }
fn show(&mut self) -> Result<()> { fn show(&mut self) -> Result<()> {
self.visible = true; self.visible = true;
self.index.show()?;
self.index_wd.show()?;
self.check_remotes(); self.check_remotes();
self.update()?; self.update()?;