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(); let files_count = self.file_tree.file_count();
if loading { format!(
strings::commit::DETAILS_FILES_LOADING_TITLE.to_string() "{} {}",
} else { strings::commit::DETAILS_FILES_TITLE,
format!( files_count
"{} {}", )
strings::commit::DETAILS_FILES_TITLE,
files_count
)
}
} }
/// ///
@ -78,19 +74,18 @@ impl CommitDetailsComponent {
{ {
if fetched_id == id { if fetched_id == id {
self.file_tree.update(res.as_slice())?; self.file_tree.update(res.as_slice())?;
self.file_tree self.file_tree.set_title(self.get_files_title());
.set_title(self.get_files_title(false));
return Ok(()); return Ok(());
} }
} }
self.file_tree.clear()?; self.file_tree.clear()?;
self.git_commit_files.fetch(id)?; 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(()) Ok(())
} }

View file

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

View file

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