mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
enhance: reduce the times calling Save()
(#436)
This commit is contained in:
parent
9fe8ffcea9
commit
931831431b
4 changed files with 18 additions and 13 deletions
|
@ -27,7 +27,7 @@ namespace SourceGit.ViewModels
|
|||
Name = _name,
|
||||
IsRepository = false,
|
||||
IsExpanded = false,
|
||||
}, _parent);
|
||||
}, _parent, true);
|
||||
|
||||
Welcome.Instance.Refresh();
|
||||
return null;
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public override Task<bool> Sure()
|
||||
{
|
||||
Preference.Instance.RemoveNode(_node);
|
||||
Preference.Instance.RemoveNode(_node, true);
|
||||
Welcome.Instance.Refresh();
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -343,7 +343,7 @@ namespace SourceGit.ViewModels
|
|||
return true;
|
||||
}
|
||||
|
||||
public void AddNode(RepositoryNode node, RepositoryNode to = null)
|
||||
public void AddNode(RepositoryNode node, RepositoryNode to, bool save)
|
||||
{
|
||||
var collection = to == null ? RepositoryNodes : to.SubNodes;
|
||||
collection.Add(node);
|
||||
|
@ -355,7 +355,8 @@ namespace SourceGit.ViewModels
|
|||
return string.Compare(l.Name, r.Name, StringComparison.Ordinal);
|
||||
});
|
||||
|
||||
Save();
|
||||
if (save)
|
||||
Save();
|
||||
}
|
||||
|
||||
public RepositoryNode FindNode(string id)
|
||||
|
@ -376,32 +377,36 @@ namespace SourceGit.ViewModels
|
|||
IsRepository = true,
|
||||
};
|
||||
|
||||
AddNode(node, parent);
|
||||
AddNode(node, parent, true);
|
||||
}
|
||||
else if (shouldMoveNode)
|
||||
{
|
||||
MoveNode(node, parent);
|
||||
MoveNode(node, parent, true);
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
public void MoveNode(RepositoryNode node, RepositoryNode to = null)
|
||||
public void MoveNode(RepositoryNode node, RepositoryNode to, bool save)
|
||||
{
|
||||
if (to == null && RepositoryNodes.Contains(node))
|
||||
return;
|
||||
if (to != null && to.SubNodes.Contains(node))
|
||||
return;
|
||||
|
||||
RemoveNode(node);
|
||||
AddNode(node, to);
|
||||
Save();
|
||||
RemoveNode(node, false);
|
||||
AddNode(node, to, false);
|
||||
|
||||
if (save)
|
||||
Save();
|
||||
}
|
||||
|
||||
public void RemoveNode(RepositoryNode node)
|
||||
public void RemoveNode(RepositoryNode node, bool save)
|
||||
{
|
||||
RemoveNodeRecursive(node, RepositoryNodes);
|
||||
Save();
|
||||
|
||||
if (save)
|
||||
Save();
|
||||
}
|
||||
|
||||
public void SortByRenamedNode(RepositoryNode node)
|
||||
|
|
|
@ -139,7 +139,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
public void MoveNode(RepositoryNode from, RepositoryNode to)
|
||||
{
|
||||
Preference.Instance.MoveNode(from, to);
|
||||
Preference.Instance.MoveNode(from, to, true);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue