mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
optimize<Histories>: move UpdateCommits from Histories to Dashboard
This commit is contained in:
parent
932db894a5
commit
776defe6c3
2 changed files with 32 additions and 11 deletions
|
@ -19,6 +19,7 @@ namespace SourceGit.Views.Widgets {
|
||||||
private Models.Repository repo = null;
|
private Models.Repository repo = null;
|
||||||
private List<BranchNode> localBranches = new List<BranchNode>();
|
private List<BranchNode> localBranches = new List<BranchNode>();
|
||||||
private List<BranchNode> remoteBranches = new List<BranchNode>();
|
private List<BranchNode> remoteBranches = new List<BranchNode>();
|
||||||
|
private bool isFirstLoaded = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 节点类型
|
/// 节点类型
|
||||||
|
@ -58,12 +59,15 @@ namespace SourceGit.Views.Widgets {
|
||||||
var watcher = Models.Watcher.Get(repo.Path);
|
var watcher = Models.Watcher.Get(repo.Path);
|
||||||
watcher.Navigate += NavigateTo;
|
watcher.Navigate += NavigateTo;
|
||||||
watcher.BranchChanged += UpdateBraches;
|
watcher.BranchChanged += UpdateBraches;
|
||||||
|
watcher.BranchChanged += UpdateCommits;
|
||||||
watcher.WorkingCopyChanged += UpdateWorkingCopy;
|
watcher.WorkingCopyChanged += UpdateWorkingCopy;
|
||||||
watcher.StashChanged += UpdateStashes;
|
watcher.StashChanged += UpdateStashes;
|
||||||
watcher.TagChanged += UpdateTags;
|
watcher.TagChanged += UpdateTags;
|
||||||
|
watcher.TagChanged += UpdateCommits;
|
||||||
watcher.SubmoduleChanged += UpdateSubmodules;
|
watcher.SubmoduleChanged += UpdateSubmodules;
|
||||||
watcher.SubTreeChanged += UpdateSubTrees;
|
watcher.SubTreeChanged += UpdateSubTrees;
|
||||||
|
|
||||||
|
IsVisibleChanged += OnVisibleChanged;
|
||||||
Unloaded += (o, e) => {
|
Unloaded += (o, e) => {
|
||||||
localBranches.Clear();
|
localBranches.Clear();
|
||||||
remoteBranches.Clear();
|
remoteBranches.Clear();
|
||||||
|
@ -72,12 +76,6 @@ namespace SourceGit.Views.Widgets {
|
||||||
tagList.ItemsSource = new List<Models.Tag>();
|
tagList.ItemsSource = new List<Models.Tag>();
|
||||||
submoduleList.ItemsSource = new List<string>();
|
submoduleList.ItemsSource = new List<string>();
|
||||||
};
|
};
|
||||||
|
|
||||||
void FirstShowHandler(object _, DependencyPropertyChangedEventArgs __) {
|
|
||||||
IsVisibleChanged -= FirstShowHandler;
|
|
||||||
Refresh();
|
|
||||||
}
|
|
||||||
IsVisibleChanged += FirstShowHandler;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#region POPUP
|
#region POPUP
|
||||||
|
@ -102,9 +100,19 @@ namespace SourceGit.Views.Widgets {
|
||||||
UpdateTags();
|
UpdateTags();
|
||||||
UpdateSubmodules();
|
UpdateSubmodules();
|
||||||
UpdateSubTrees();
|
UpdateSubTrees();
|
||||||
|
UpdateCommits();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnVisibleChanged(object sender, DependencyPropertyChangedEventArgs ev) {
|
||||||
|
if (IsVisible && !isFirstLoaded) {
|
||||||
|
isFirstLoaded = true;
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NavigateTo(string commitId) {
|
private void NavigateTo(string commitId) {
|
||||||
|
if (!isFirstLoaded) return;
|
||||||
|
|
||||||
workspace.SelectedIndex = 0;
|
workspace.SelectedIndex = 0;
|
||||||
(pages.Get("histories") as Histories).NavigateTo(commitId);
|
(pages.Get("histories") as Histories).NavigateTo(commitId);
|
||||||
}
|
}
|
||||||
|
@ -183,6 +191,8 @@ namespace SourceGit.Views.Widgets {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateBraches() {
|
private void UpdateBraches() {
|
||||||
|
if (!isFirstLoaded) return;
|
||||||
|
|
||||||
Task.Run(() => {
|
Task.Run(() => {
|
||||||
repo.Branches = new Commands.Branches(repo.Path).Result();
|
repo.Branches = new Commands.Branches(repo.Path).Result();
|
||||||
repo.Remotes = new Commands.Remotes(repo.Path).Result();
|
repo.Remotes = new Commands.Remotes(repo.Path).Result();
|
||||||
|
@ -227,6 +237,8 @@ namespace SourceGit.Views.Widgets {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateWorkingCopy() {
|
private void UpdateWorkingCopy() {
|
||||||
|
if (!isFirstLoaded) return;
|
||||||
|
|
||||||
Task.Run(() => {
|
Task.Run(() => {
|
||||||
var changes = new Commands.LocalChanges(repo.Path).Result();
|
var changes = new Commands.LocalChanges(repo.Path).Result();
|
||||||
Dispatcher.Invoke(() => {
|
Dispatcher.Invoke(() => {
|
||||||
|
@ -238,6 +250,8 @@ namespace SourceGit.Views.Widgets {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateStashes() {
|
private void UpdateStashes() {
|
||||||
|
if (!isFirstLoaded) return;
|
||||||
|
|
||||||
Task.Run(() => {
|
Task.Run(() => {
|
||||||
var stashes = new Commands.Stashes(repo.Path).Result();
|
var stashes = new Commands.Stashes(repo.Path).Result();
|
||||||
Dispatcher.Invoke(() => {
|
Dispatcher.Invoke(() => {
|
||||||
|
@ -248,6 +262,8 @@ namespace SourceGit.Views.Widgets {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateTags() {
|
private void UpdateTags() {
|
||||||
|
if (!isFirstLoaded) return;
|
||||||
|
|
||||||
Task.Run(() => {
|
Task.Run(() => {
|
||||||
var tags = new Commands.Tags(repo.Path).Result();
|
var tags = new Commands.Tags(repo.Path).Result();
|
||||||
foreach (var t in tags) t.IsFiltered = repo.Filters.Contains(t.Name);
|
foreach (var t in tags) t.IsFiltered = repo.Filters.Contains(t.Name);
|
||||||
|
@ -259,6 +275,8 @@ namespace SourceGit.Views.Widgets {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateSubmodules() {
|
private void UpdateSubmodules() {
|
||||||
|
if (!isFirstLoaded) return;
|
||||||
|
|
||||||
Task.Run(() => {
|
Task.Run(() => {
|
||||||
var submodules = new Commands.Submodules(repo.Path).Result();
|
var submodules = new Commands.Submodules(repo.Path).Result();
|
||||||
Dispatcher.Invoke(() => {
|
Dispatcher.Invoke(() => {
|
||||||
|
@ -269,12 +287,20 @@ namespace SourceGit.Views.Widgets {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateSubTrees() {
|
private void UpdateSubTrees() {
|
||||||
|
if (!isFirstLoaded) return;
|
||||||
|
|
||||||
Dispatcher.Invoke(() => {
|
Dispatcher.Invoke(() => {
|
||||||
txtSubTreeCount.Text = $"({repo.SubTrees.Count})";
|
txtSubTreeCount.Text = $"({repo.SubTrees.Count})";
|
||||||
subTreeList.ItemsSource = null;
|
subTreeList.ItemsSource = null;
|
||||||
subTreeList.ItemsSource = repo.SubTrees;
|
subTreeList.ItemsSource = repo.SubTrees;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void UpdateCommits() {
|
||||||
|
if (!isFirstLoaded) return;
|
||||||
|
|
||||||
|
(pages.Get("histories") as Histories).UpdateCommits();
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region TOOLBAR_COMMANDS
|
#region TOOLBAR_COMMANDS
|
||||||
|
|
|
@ -22,11 +22,6 @@ namespace SourceGit.Views.Widgets {
|
||||||
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
ChangeOrientation(null, null);
|
ChangeOrientation(null, null);
|
||||||
UpdateCommits();
|
|
||||||
|
|
||||||
var watcher = Models.Watcher.Get(repo.Path);
|
|
||||||
watcher.BranchChanged += UpdateCommits;
|
|
||||||
watcher.TagChanged += UpdateCommits;
|
|
||||||
|
|
||||||
Unloaded += (o, e) => {
|
Unloaded += (o, e) => {
|
||||||
cachedCommits.Clear();
|
cachedCommits.Clear();
|
||||||
|
|
Loading…
Reference in a new issue