mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08: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,
|
Name = _name,
|
||||||
IsRepository = false,
|
IsRepository = false,
|
||||||
IsExpanded = false,
|
IsExpanded = false,
|
||||||
}, _parent);
|
}, _parent, true);
|
||||||
|
|
||||||
Welcome.Instance.Refresh();
|
Welcome.Instance.Refresh();
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
public override Task<bool> Sure()
|
public override Task<bool> Sure()
|
||||||
{
|
{
|
||||||
Preference.Instance.RemoveNode(_node);
|
Preference.Instance.RemoveNode(_node, true);
|
||||||
Welcome.Instance.Refresh();
|
Welcome.Instance.Refresh();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -343,7 +343,7 @@ namespace SourceGit.ViewModels
|
||||||
return true;
|
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;
|
var collection = to == null ? RepositoryNodes : to.SubNodes;
|
||||||
collection.Add(node);
|
collection.Add(node);
|
||||||
|
@ -355,6 +355,7 @@ namespace SourceGit.ViewModels
|
||||||
return string.Compare(l.Name, r.Name, StringComparison.Ordinal);
|
return string.Compare(l.Name, r.Name, StringComparison.Ordinal);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (save)
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,31 +377,35 @@ namespace SourceGit.ViewModels
|
||||||
IsRepository = true,
|
IsRepository = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
AddNode(node, parent);
|
AddNode(node, parent, true);
|
||||||
}
|
}
|
||||||
else if (shouldMoveNode)
|
else if (shouldMoveNode)
|
||||||
{
|
{
|
||||||
MoveNode(node, parent);
|
MoveNode(node, parent, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return node;
|
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))
|
if (to == null && RepositoryNodes.Contains(node))
|
||||||
return;
|
return;
|
||||||
if (to != null && to.SubNodes.Contains(node))
|
if (to != null && to.SubNodes.Contains(node))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
RemoveNode(node);
|
RemoveNode(node, false);
|
||||||
AddNode(node, to);
|
AddNode(node, to, false);
|
||||||
|
|
||||||
|
if (save)
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveNode(RepositoryNode node)
|
public void RemoveNode(RepositoryNode node, bool save)
|
||||||
{
|
{
|
||||||
RemoveNodeRecursive(node, RepositoryNodes);
|
RemoveNodeRecursive(node, RepositoryNodes);
|
||||||
|
|
||||||
|
if (save)
|
||||||
Save();
|
Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ namespace SourceGit.ViewModels
|
||||||
|
|
||||||
public void MoveNode(RepositoryNode from, RepositoryNode to)
|
public void MoveNode(RepositoryNode from, RepositoryNode to)
|
||||||
{
|
{
|
||||||
Preference.Instance.MoveNode(from, to);
|
Preference.Instance.MoveNode(from, to, true);
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue