From 4ee9234289c682663373e54c81eeb7dd0eab9cf5 Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 21 Dec 2020 11:07:30 +0800 Subject: [PATCH] optimize: do NOT update commits without log filter changes --- src/UI/Dashboard.xaml.cs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/UI/Dashboard.xaml.cs b/src/UI/Dashboard.xaml.cs index f3e170f7..b4463a70 100644 --- a/src/UI/Dashboard.xaml.cs +++ b/src/UI/Dashboard.xaml.cs @@ -1094,6 +1094,8 @@ namespace SourceGit.UI { var toggle = sender as ToggleButton; if (toggle == null) return; + var changed = false; + if (toggle.DataContext is BranchNode) { var branch = (toggle.DataContext as BranchNode).Branch; if (branch == null) return; @@ -1101,16 +1103,24 @@ namespace SourceGit.UI { if (toggle.IsChecked == true) { if (!repo.LogFilters.Contains(branch.FullName)) { repo.LogFilters.Add(branch.FullName); + changed = true; } + if (!string.IsNullOrEmpty(branch.Upstream) && !repo.LogFilters.Contains(branch.Upstream)) { repo.LogFilters.Add(branch.Upstream); UpdateBranches(false); + changed = true; } } else { - repo.LogFilters.Remove(branch.FullName); - if (!string.IsNullOrEmpty(branch.Upstream)) { + if (repo.LogFilters.Contains(branch.FullName)) { + repo.LogFilters.Remove(branch.FullName); + changed = true; + } + + if (!string.IsNullOrEmpty(branch.Upstream) && repo.LogFilters.Contains(branch.Upstream)) { repo.LogFilters.Remove(branch.Upstream); UpdateBranches(false); + changed = true; } } } @@ -1121,13 +1131,17 @@ namespace SourceGit.UI { if (toggle.IsChecked == true) { if (!repo.LogFilters.Contains(tag.Name)) { repo.LogFilters.Add(tag.Name); + changed = true; } } else { - repo.LogFilters.Remove(tag.Name); + if (repo.LogFilters.Contains(tag.Name)) { + repo.LogFilters.Remove(tag.Name); + changed = true; + } } } - UpdateHistories(); + if (changed) UpdateHistories(); } #endregion }