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

Commit 04b03fc

Browse files
Moving methods
1 parent d64f2cd commit 04b03fc

File tree

1 file changed

+62
-63
lines changed

1 file changed

+62
-63
lines changed

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

Lines changed: 62 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -35,52 +35,6 @@ public override void InitializeView(IView parent)
3535
tree.InitializeView(this);
3636
}
3737

38-
private void RepositoryOnStatusChanged(CacheUpdateEvent cacheUpdateEvent)
39-
{
40-
if (!lastStatusChangedEvent.Equals(cacheUpdateEvent))
41-
{
42-
new ActionTask(TaskManager.Token, () =>
43-
{
44-
lastStatusChangedEvent = cacheUpdateEvent;
45-
currentStatusHasUpdate = true;
46-
Redraw();
47-
})
48-
{ Affinity = TaskAffinity.UI }.Start();
49-
}
50-
}
51-
52-
private void RepositoryOnCurrentBranchChanged(CacheUpdateEvent cacheUpdateEvent)
53-
{
54-
if (!lastCurrentBranchChangedEvent.Equals(cacheUpdateEvent))
55-
{
56-
new ActionTask(TaskManager.Token, () =>
57-
{
58-
lastCurrentBranchChangedEvent = cacheUpdateEvent;
59-
currentBranchHasUpdate = true;
60-
Redraw();
61-
})
62-
{ Affinity = TaskAffinity.UI }.Start();
63-
}
64-
}
65-
66-
private void AttachHandlers(IRepository repository)
67-
{
68-
if (repository == null)
69-
return;
70-
71-
repository.CurrentBranchChanged += RepositoryOnCurrentBranchChanged;
72-
repository.StatusChanged += RepositoryOnStatusChanged;
73-
}
74-
75-
private void DetachHandlers(IRepository repository)
76-
{
77-
if (repository == null)
78-
return;
79-
80-
repository.CurrentBranchChanged -= RepositoryOnCurrentBranchChanged;
81-
repository.StatusChanged -= RepositoryOnStatusChanged;
82-
}
83-
8438
public override void OnEnable()
8539
{
8640
base.OnEnable();
@@ -106,22 +60,6 @@ public override void OnDataUpdate()
10660
MaybeUpdateData();
10761
}
10862

109-
private void MaybeUpdateData()
110-
{
111-
if (currentBranchHasUpdate)
112-
{
113-
currentBranchHasUpdate = false;
114-
currentBranch = string.Format("[{0}]", Repository.CurrentBranchName);
115-
}
116-
117-
if (currentStatusHasUpdate)
118-
{
119-
currentStatusHasUpdate = false;
120-
var gitStatus = Repository.CurrentStatus;
121-
tree.UpdateEntries(gitStatus.Entries.Where(x => x.Status != GitFileStatus.Ignored).ToList());
122-
}
123-
}
124-
12563
public override void OnGUI()
12664
{
12765
GUILayout.BeginHorizontal();
@@ -160,11 +98,72 @@ public override void OnGUI()
16098
GUILayout.EndHorizontal();
16199
GUILayout.EndScrollView();
162100

163-
164101
// Do the commit details area
165102
OnCommitDetailsAreaGUI();
166103
}
167104

105+
private void RepositoryOnStatusChanged(CacheUpdateEvent cacheUpdateEvent)
106+
{
107+
if (!lastStatusChangedEvent.Equals(cacheUpdateEvent))
108+
{
109+
new ActionTask(TaskManager.Token, () => {
110+
lastStatusChangedEvent = cacheUpdateEvent;
111+
currentStatusHasUpdate = true;
112+
Redraw();
113+
}) { Affinity = TaskAffinity.UI }.Start();
114+
}
115+
}
116+
117+
private void RepositoryOnCurrentBranchChanged(CacheUpdateEvent cacheUpdateEvent)
118+
{
119+
if (!lastCurrentBranchChangedEvent.Equals(cacheUpdateEvent))
120+
{
121+
new ActionTask(TaskManager.Token, () => {
122+
lastCurrentBranchChangedEvent = cacheUpdateEvent;
123+
currentBranchHasUpdate = true;
124+
Redraw();
125+
}) { Affinity = TaskAffinity.UI }.Start();
126+
}
127+
}
128+
129+
private void AttachHandlers(IRepository repository)
130+
{
131+
if (repository == null)
132+
{
133+
return;
134+
}
135+
136+
repository.CurrentBranchChanged += RepositoryOnCurrentBranchChanged;
137+
repository.StatusChanged += RepositoryOnStatusChanged;
138+
}
139+
140+
private void DetachHandlers(IRepository repository)
141+
{
142+
if (repository == null)
143+
{
144+
return;
145+
}
146+
147+
repository.CurrentBranchChanged -= RepositoryOnCurrentBranchChanged;
148+
repository.StatusChanged -= RepositoryOnStatusChanged;
149+
}
150+
151+
private void MaybeUpdateData()
152+
{
153+
if (currentBranchHasUpdate)
154+
{
155+
currentBranchHasUpdate = false;
156+
currentBranch = string.Format("[{0}]", Repository.CurrentBranchName);
157+
}
158+
159+
if (currentStatusHasUpdate)
160+
{
161+
currentStatusHasUpdate = false;
162+
var gitStatus = Repository.CurrentStatus;
163+
tree.UpdateEntries(gitStatus.Entries.Where(x => x.Status != GitFileStatus.Ignored).ToList());
164+
}
165+
}
166+
168167
private void OnCommitDetailsAreaGUI()
169168
{
170169
GUILayout.BeginHorizontal();

0 commit comments

Comments
 (0)