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

Commit 9510e89

Browse files
Refactoring Window.MaybeUpdateData
1 parent 2f38e6a commit 9510e89

File tree

1 file changed

+16
-17
lines changed
  • src/UnityExtension/Assets/Editor/GitHub.Unity/UI

1 file changed

+16
-17
lines changed

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -109,19 +109,7 @@ public override void OnDataUpdate()
109109
{
110110
base.OnDataUpdate();
111111

112-
string repoRemote = null;
113-
if (MaybeUpdateData(out repoRemote))
114-
{
115-
repoBranchContent = new GUIContent(repoBranch, Window_RepoBranchTooltip);
116-
if (repoUrl != null)
117-
{
118-
repoUrlContent = new GUIContent(repoUrl, string.Format(Window_RepoUrlTooltip, repoRemote));
119-
}
120-
else
121-
{
122-
repoUrlContent = new GUIContent(repoUrl, Window_RepoNoUrlTooltip);
123-
}
124-
}
112+
MaybeUpdateData();
125113

126114
if (ActiveView != null)
127115
ActiveView.OnDataUpdate();
@@ -198,10 +186,10 @@ private void RefreshOnMainThread()
198186
new ActionTask(TaskManager.Token, Refresh) { Affinity = TaskAffinity.UI }.Start();
199187
}
200188

201-
private bool MaybeUpdateData(out string repoRemote)
189+
private void MaybeUpdateData()
202190
{
203-
repoRemote = null;
204-
bool repoDataChanged = false;
191+
string repoRemote = null;
192+
var repoDataChanged = false;
205193
if (Repository != null)
206194
{
207195
var currentBranchString = (Repository.CurrentBranch.HasValue ? Repository.CurrentBranch.Value.Name : null);
@@ -236,7 +224,18 @@ private bool MaybeUpdateData(out string repoRemote)
236224
}
237225
}
238226

239-
return repoDataChanged;
227+
if (repoDataChanged)
228+
{
229+
repoBranchContent = new GUIContent(repoBranch, Window_RepoBranchTooltip);
230+
if (repoUrl != null)
231+
{
232+
repoUrlContent = new GUIContent(repoUrl, string.Format(Window_RepoUrlTooltip, repoRemote));
233+
}
234+
else
235+
{
236+
repoUrlContent = new GUIContent(repoUrl, Window_RepoNoUrlTooltip);
237+
}
238+
}
240239
}
241240

242241
private void AttachHandlers(IRepository repository)

0 commit comments

Comments
 (0)