Skip to content
This repository was archived by the owner on Dec 5, 2024. It is now read-only.

Commit 97b77cc

Browse files
Remove stateChangeCallback because it is never used
1 parent 9e13714 commit 97b77cc

File tree

1 file changed

+4
-32
lines changed

1 file changed

+4
-32
lines changed

src/UnityExtension/Assets/Editor/GitHub.Unity/UI/ChangesetTreeView.cs

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class ChangesetTreeView : Subview
1919
[SerializeField] private List<GitCommitTarget> entryCommitTargets = new List<GitCommitTarget>();
2020
[SerializeField] private List<string> foldedTreeEntries = new List<string>();
2121
[NonSerialized] private FileTreeNode tree;
22-
[NonSerialized] private Action<FileTreeNode> stateChangeCallback;
2322

2423
public override void OnGUI()
2524
{
@@ -153,15 +152,15 @@ public void UpdateEntries(IList<GitStatusEntry> newEntries)
153152

154153
// Build tree structure
155154

156-
tree = new FileTreeNode(FileSystemHelpers.FindCommonPath(entries.Select(e => e.Path)), stateChangeCallback);
155+
tree = new FileTreeNode(FileSystemHelpers.FindCommonPath(entries.Select(e => e.Path)));
157156
tree.RepositoryPath = tree.Path;
158157
for (var index = 0; index < entries.Count; index++)
159158
{
160159
var entryPath = entries[index].Path.ToNPath();
161160
if (entryPath.IsChildOf(tree.Path))
162161
entryPath = entryPath.RelativeTo(tree.Path.ToNPath());
163162

164-
var node = new FileTreeNode(entryPath, stateChangeCallback) { Target = entryCommitTargets[index] };
163+
var node = new FileTreeNode(entryPath) { Target = entryCommitTargets[index] };
165164
if (!string.IsNullOrEmpty(entries[index].ProjectPath))
166165
{
167166
node.Icon = AssetDatabase.GetCachedIcon(entries[index].ProjectPath);
@@ -209,7 +208,7 @@ private void BuildTree(FileTreeNode parent, FileTreeNode node)
209208
if (!found)
210209
{
211210
var p = parent.RepositoryPath.ToNPath().Combine(root);
212-
BuildTree(parent.Add(new FileTreeNode(root, stateChangeCallback) { RepositoryPath = p }), node);
211+
BuildTree(parent.Add(new FileTreeNode(root) { RepositoryPath = p }), node);
213212
}
214213
}
215214
else if (nodePath.ExtensionWithDot == ".meta")
@@ -259,25 +258,7 @@ private void TreeNode(FileTreeNode node)
259258
}
260259
if (EditorGUI.EndChangeCheck())
261260
{
262-
var filesAdded = new List<string>();
263-
var filesRemoved = new List<string>();
264-
stateChangeCallback = new Action<FileTreeNode>(s =>
265-
{
266-
if (s.State == CommitState.None)
267-
filesRemoved.Add(s.Path);
268-
else
269-
filesAdded.Add(s.Path);
270-
});
271261
node.State = toggled ? CommitState.All : CommitState.None;
272-
if (filesAdded.Count > 0)
273-
GitClient.Add(filesAdded);
274-
if (filesRemoved.Count > 0)
275-
GitClient.Remove(filesAdded);
276-
if (filesAdded.Count > 0|| filesRemoved.Count > 0)
277-
{
278-
GitClient.Status();
279-
}
280-
// we might need to run git status after these calls
281262
}
282263
}
283264

@@ -421,7 +402,6 @@ private enum CommitState
421402

422403
private class FileTreeNode
423404
{
424-
private readonly Action<FileTreeNode> stateChangeCallback;
425405
private List<FileTreeNode> children;
426406
private string path;
427407
private CommitState state;
@@ -432,15 +412,8 @@ private class FileTreeNode
432412
public string RepositoryPath;
433413
public GitCommitTarget Target { get; set; }
434414

435-
public FileTreeNode(Action<FileTreeNode> stateChangeCallback)
436-
{
437-
this.stateChangeCallback = stateChangeCallback;
438-
children = new List<FileTreeNode>();
439-
}
440-
441-
public FileTreeNode(string path, Action<FileTreeNode> stateChangeCallback)
415+
public FileTreeNode(string path)
442416
{
443-
this.stateChangeCallback = stateChangeCallback;
444417
this.path = path ?? "";
445418
Label = this.path;
446419
children = new List<FileTreeNode>();
@@ -514,7 +487,6 @@ public CommitState State
514487
}
515488

516489
state = value;
517-
stateChangeCallback.SafeInvoke(this);
518490

519491
if (children == null)
520492
{

0 commit comments

Comments
 (0)