From 7e8df3ad282336f0d7cab3fffc44173829702ebb Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Sat, 18 Jul 2020 13:35:24 +0200 Subject: [PATCH] simplify pending state by using the new one --- src/components/commit_details/mod.rs | 25 ++++++++++--------------- src/components/filetree.rs | 1 + src/strings.rs | 1 - 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/components/commit_details/mod.rs b/src/components/commit_details/mod.rs index aa8347a0..36d906eb 100644 --- a/src/components/commit_details/mod.rs +++ b/src/components/commit_details/mod.rs @@ -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(()) } diff --git a/src/components/filetree.rs b/src/components/filetree.rs index 02478ae4..21eb1e51 100644 --- a/src/components/filetree.rs +++ b/src/components/filetree.rs @@ -104,6 +104,7 @@ impl FileTreeComponent { /// pub fn clear(&mut self) -> Result<()> { self.current_hash = 0; + self.pending = true; self.tree.update(&[]) } diff --git a/src/strings.rs b/src/strings.rs index 509dffb8..e4be0bf0 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -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 {