diff --git a/CHANGELOG.md b/CHANGELOG.md index 94522b09..de4beaa1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - reset file inside folder failed when running `gitui` in a subfolder too ([#118](https://github.com/extrawurst/gitui/issues/118)) - selection could disappear into collapsed folder ([#120](https://github.com/extrawurst/gitui/issues/120)) +- `Files: loading` sometimes wrong ([#119](https://github.com/extrawurst/gitui/issues/119)) ## [0.6.0] - 2020-06-09 diff --git a/src/components/commit_details/mod.rs b/src/components/commit_details/mod.rs index fe877575..7115330c 100644 --- a/src/components/commit_details/mod.rs +++ b/src/components/commit_details/mod.rs @@ -48,11 +48,10 @@ impl CommitDetailsComponent { } } - fn get_files_title(&self) -> String { - let files_loading = self.git_commit_files.is_pending(); + fn get_files_title(&self, loading: bool) -> String { let files_count = self.file_tree.file_count(); - if files_loading { + if loading { strings::commit::DETAILS_FILES_LOADING_TITLE.to_string() } else { format!( @@ -77,17 +76,18 @@ impl CommitDetailsComponent { { if fetched_id == id { self.file_tree.update(res.as_slice())?; - } else { - self.file_tree.clear()?; - self.git_commit_files.fetch(id)?; - } - } else { - self.file_tree.clear()?; - self.git_commit_files.fetch(id)?; - } - } + 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)); + } Ok(()) }