simplify pending state by using the new one

This commit is contained in:
Stephan Dilly 2020-07-18 13:35:24 +02:00
parent 03cf23ad98
commit 7e8df3ad28
3 changed files with 11 additions and 16 deletions

View File

@ -50,18 +50,14 @@ impl CommitDetailsComponent {
}
}
fn get_files_title(&self, loading: bool) -> String {
fn get_files_title(&self) -> String {
let files_count = self.file_tree.file_count();
if loading {
strings::commit::DETAILS_FILES_LOADING_TITLE.to_string()
} else {
format!(
"{} {}",
strings::commit::DETAILS_FILES_TITLE,
files_count
)
}
format!(
"{} {}",
strings::commit::DETAILS_FILES_TITLE,
files_count
)
}
///
@ -78,19 +74,18 @@ impl CommitDetailsComponent {
{
if fetched_id == id {
self.file_tree.update(res.as_slice())?;
self.file_tree
.set_title(self.get_files_title(false));
self.file_tree.set_title(self.get_files_title());
return Ok(());
}
}
self.file_tree.clear()?;
self.git_commit_files.fetch(id)?;
self.file_tree.set_title(self.get_files_title(true));
} else {
self.file_tree.set_title(self.get_files_title(false));
}
self.file_tree.set_title(self.get_files_title());
Ok(())
}

View File

@ -104,6 +104,7 @@ impl FileTreeComponent {
///
pub fn clear(&mut self) -> Result<()> {
self.current_hash = 0;
self.pending = true;
self.tree.update(&[])
}

View File

@ -50,7 +50,6 @@ pub mod commit {
pub static DETAILS_INFO_TITLE: &str = "Info";
pub static DETAILS_MESSAGE_TITLE: &str = "Message";
pub static DETAILS_FILES_TITLE: &str = "Files:";
pub static DETAILS_FILES_LOADING_TITLE: &str = "Files: loading";
}
pub mod order {