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

Commit 890237b

Browse files
Merge branch 'fixes/init-proj-view-spam' into fixes/git-client-set-user
2 parents 2b0ebf5 + fca75da commit 890237b

File tree

1 file changed

+36
-27
lines changed

1 file changed

+36
-27
lines changed

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

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ class UserSettingsView : Subview
2222
[SerializeField] private string gitEmail;
2323
[SerializeField] private string newGitName;
2424
[SerializeField] private string newGitEmail;
25-
[SerializeField] private User cachedUser;
2625

2726
public override void InitializeView(IView parent)
2827
{
@@ -63,7 +62,7 @@ public override void OnGUI()
6362
{
6463
if (Repository != null)
6564
{
66-
Repository.User.Name = newGitName;
65+
Repository.User.Name = gitName = newGitName;
6766
Repository.User.Email = newGitEmail;
6867
}
6968
else
@@ -88,43 +87,53 @@ public override void OnGUI()
8887
EditorGUI.EndDisabledGroup();
8988
}
9089

90+
public override void OnEnable()
91+
{
92+
base.OnEnable();
93+
userDataHasChanged = true;
94+
}
95+
9196
private void MaybeUpdateData()
9297
{
93-
if (Repository == null)
98+
if (userDataHasChanged)
9499
{
95-
if (!String.IsNullOrEmpty(EntryPoint.Environment.GitExecutablePath))
100+
userDataHasChanged = false;
101+
102+
if (Repository == null)
96103
{
97-
if ((cachedUser == null || String.IsNullOrEmpty(cachedUser.Name)) && GitClient != null)
98-
{
99-
GitClient.GetConfigUserAndEmail().FinallyInUI((success, ex, user) => {
100-
if (success && !String.IsNullOrEmpty(user.Name) && !String.IsNullOrEmpty(user.Email))
101-
{
102-
cachedUser = user;
103-
104-
userDataHasChanged = true;
105-
Redraw();
106-
}
107-
}).Start();
108-
}
104+
UpdateUserDataFromClient();
109105
}
110-
111-
if (userDataHasChanged)
106+
else
112107
{
113-
newGitName = gitName = cachedUser.Name;
114-
newGitEmail = gitEmail = cachedUser.Email;
115-
userDataHasChanged = false;
108+
newGitName = gitName = Repository.User.Name;
109+
newGitEmail = gitEmail = Repository.User.Email;
116110
}
117-
return;
118111
}
112+
}
119113

120-
userDataHasChanged = Repository.User.Name != gitName || Repository.User.Email != gitEmail;
114+
private void UpdateUserDataFromClient()
115+
{
116+
if (String.IsNullOrEmpty(EntryPoint.Environment.GitExecutablePath))
117+
{
118+
return;
119+
}
121120

122-
if (!userDataHasChanged)
121+
if (GitClient == null)
122+
{
123123
return;
124+
}
125+
126+
Logger.Trace("Update user data from GitClient");
124127

125-
userDataHasChanged = false;
126-
newGitName = gitName = Repository.User.Name;
127-
newGitEmail = gitEmail = Repository.User.Email;
128+
GitClient.GetConfigUserAndEmail()
129+
.ThenInUI((success, user) => {
130+
if (success && !String.IsNullOrEmpty(user.Name) && !String.IsNullOrEmpty(user.Email))
131+
{
132+
newGitName = gitName = user.Name;
133+
newGitEmail = gitEmail = user.Email;
134+
Redraw();
135+
}
136+
}).Start();
128137
}
129138

130139
public override bool IsBusy

0 commit comments

Comments
 (0)