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

Commit 8b57bb9

Browse files
Checking for changes to save in a timely fashion
1 parent d86c162 commit 8b57bb9

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

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

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ class UserSettingsView : Subview
2222
[SerializeField] private string gitEmail;
2323
[SerializeField] private string newGitName;
2424
[SerializeField] private string newGitEmail;
25+
[SerializeField] private bool needsSaving;
2526

2627
public override void InitializeView(IView parent)
2728
{
@@ -42,11 +43,17 @@ public override void OnGUI()
4243

4344
EditorGUI.BeginDisabledGroup(IsBusy || Parent.IsBusy);
4445
{
45-
newGitName = EditorGUILayout.TextField(GitConfigNameLabel, newGitName);
46-
newGitEmail = EditorGUILayout.TextField(GitConfigEmailLabel, newGitEmail);
46+
EditorGUI.BeginChangeCheck();
47+
{
48+
newGitName = EditorGUILayout.TextField(GitConfigNameLabel, newGitName);
49+
newGitEmail = EditorGUILayout.TextField(GitConfigEmailLabel, newGitEmail);
50+
}
4751

48-
var needsSaving = (newGitName != gitName || newGitEmail != gitEmail)
49-
&& !(string.IsNullOrEmpty(newGitName) || string.IsNullOrEmpty(newGitEmail));
52+
if (EditorGUI.EndChangeCheck())
53+
{
54+
needsSaving = !(string.IsNullOrEmpty(newGitName) || string.IsNullOrEmpty(newGitEmail))
55+
&& (newGitName != gitName || newGitEmail != gitEmail);
56+
}
5057

5158
EditorGUI.BeginDisabledGroup(!needsSaving);
5259
{
@@ -71,6 +78,8 @@ public override void OnGUI()
7178
gitEmail = newGitEmail;
7279
}
7380

81+
needsSaving = false;
82+
7483
Redraw();
7584
Finish(true);
7685
}
@@ -103,6 +112,7 @@ private void MaybeUpdateData()
103112
{
104113
newGitName = gitName = Repository.User.Name;
105114
newGitEmail = gitEmail = Repository.User.Email;
115+
needsSaving = false;
106116
}
107117
}
108118
}
@@ -127,6 +137,7 @@ private void UpdateUserDataFromClient()
127137
{
128138
newGitName = gitName = user.Name;
129139
newGitEmail = gitEmail = user.Email;
140+
needsSaving = false;
130141
Redraw();
131142
}
132143
}).Start();

0 commit comments

Comments
 (0)