optimize<Dashboard>: do NOT update commits without log filter changes

This commit is contained in:
leo 2020-12-21 11:07:30 +08:00
parent cdc31a47e6
commit 4ee9234289

View file

@ -1094,6 +1094,8 @@ namespace SourceGit.UI {
var toggle = sender as ToggleButton; var toggle = sender as ToggleButton;
if (toggle == null) return; if (toggle == null) return;
var changed = false;
if (toggle.DataContext is BranchNode) { if (toggle.DataContext is BranchNode) {
var branch = (toggle.DataContext as BranchNode).Branch; var branch = (toggle.DataContext as BranchNode).Branch;
if (branch == null) return; if (branch == null) return;
@ -1101,16 +1103,24 @@ namespace SourceGit.UI {
if (toggle.IsChecked == true) { if (toggle.IsChecked == true) {
if (!repo.LogFilters.Contains(branch.FullName)) { if (!repo.LogFilters.Contains(branch.FullName)) {
repo.LogFilters.Add(branch.FullName); repo.LogFilters.Add(branch.FullName);
changed = true;
} }
if (!string.IsNullOrEmpty(branch.Upstream) && !repo.LogFilters.Contains(branch.Upstream)) { if (!string.IsNullOrEmpty(branch.Upstream) && !repo.LogFilters.Contains(branch.Upstream)) {
repo.LogFilters.Add(branch.Upstream); repo.LogFilters.Add(branch.Upstream);
UpdateBranches(false); UpdateBranches(false);
changed = true;
} }
} else { } else {
if (repo.LogFilters.Contains(branch.FullName)) {
repo.LogFilters.Remove(branch.FullName); repo.LogFilters.Remove(branch.FullName);
if (!string.IsNullOrEmpty(branch.Upstream)) { changed = true;
}
if (!string.IsNullOrEmpty(branch.Upstream) && repo.LogFilters.Contains(branch.Upstream)) {
repo.LogFilters.Remove(branch.Upstream); repo.LogFilters.Remove(branch.Upstream);
UpdateBranches(false); UpdateBranches(false);
changed = true;
} }
} }
} }
@ -1121,13 +1131,17 @@ namespace SourceGit.UI {
if (toggle.IsChecked == true) { if (toggle.IsChecked == true) {
if (!repo.LogFilters.Contains(tag.Name)) { if (!repo.LogFilters.Contains(tag.Name)) {
repo.LogFilters.Add(tag.Name); repo.LogFilters.Add(tag.Name);
changed = true;
} }
} else { } else {
if (repo.LogFilters.Contains(tag.Name)) {
repo.LogFilters.Remove(tag.Name); repo.LogFilters.Remove(tag.Name);
changed = true;
}
} }
} }
UpdateHistories(); if (changed) UpdateHistories();
} }
#endregion #endregion
} }