@@ -22,7 +22,6 @@ class UserSettingsView : Subview
22
22
[ SerializeField ] private string gitEmail ;
23
23
[ SerializeField ] private string newGitName ;
24
24
[ SerializeField ] private string newGitEmail ;
25
- [ SerializeField ] private User cachedUser ;
26
25
27
26
public override void InitializeView ( IView parent )
28
27
{
@@ -63,7 +62,7 @@ public override void OnGUI()
63
62
{
64
63
if ( Repository != null )
65
64
{
66
- Repository . User . Name = newGitName ;
65
+ Repository . User . Name = gitName = newGitName ;
67
66
Repository . User . Email = newGitEmail ;
68
67
}
69
68
else
@@ -88,43 +87,53 @@ public override void OnGUI()
88
87
EditorGUI . EndDisabledGroup ( ) ;
89
88
}
90
89
90
+ public override void OnEnable ( )
91
+ {
92
+ base . OnEnable ( ) ;
93
+ userDataHasChanged = true ;
94
+ }
95
+
91
96
private void MaybeUpdateData ( )
92
97
{
93
- if ( Repository == null )
98
+ if ( userDataHasChanged )
94
99
{
95
- if ( ! String . IsNullOrEmpty ( EntryPoint . Environment . GitExecutablePath ) )
100
+ userDataHasChanged = false ;
101
+
102
+ if ( Repository == null )
96
103
{
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 ( ) ;
109
105
}
110
-
111
- if ( userDataHasChanged )
106
+ else
112
107
{
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 ;
116
110
}
117
- return ;
118
111
}
112
+ }
119
113
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
+ }
121
120
122
- if ( ! userDataHasChanged )
121
+ if ( GitClient == null )
122
+ {
123
123
return ;
124
+ }
125
+
126
+ Logger . Trace ( "Update user data from GitClient" ) ;
124
127
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 ( ) ;
128
137
}
129
138
130
139
public override bool IsBusy
0 commit comments