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

Commit bf459e2

Browse files
Utilizing the git user cache better
1 parent 98a9af3 commit bf459e2

File tree

4 files changed

+29
-10
lines changed

4 files changed

+29
-10
lines changed

src/GitHub.Api/Git/GitClient.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ private void GitUserCacheOnCacheUpdated(DateTimeOffset timeOffset)
123123

124124
private void GitUserCacheOnCacheInvalidated()
125125
{
126-
126+
Logger.Trace("GitUserCache Invalidated");
127+
UpdateUserAndEmail();
127128
}
128129

129130
public void CheckUserChangedEvent(CacheUpdateEvent cacheUpdateEvent)
@@ -320,6 +321,8 @@ public ITask<string> SetConfig(string key, string value, GitConfigSource configS
320321

321322
private void UpdateUserAndEmail()
322323
{
324+
Logger.Trace("UpdateUserAndEmail");
325+
323326
string username = null;
324327
string email = null;
325328

src/GitHub.Api/Git/Repository.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,13 +665,25 @@ public interface IUser
665665
[Serializable]
666666
public class User : IUser
667667
{
668+
public string name;
669+
public string email;
670+
668671
public override string ToString()
669672
{
670673
return String.Format("Name: {0} Email: {1}", Name, Email);
671674
}
672675

673-
public string Name { get; set; }
674-
public string Email { get; set; }
676+
public string Name
677+
{
678+
get { return name; }
679+
set { name = value; }
680+
}
681+
682+
public string Email
683+
{
684+
get { return email; }
685+
set { email = value; }
686+
}
675687
}
676688

677689
[Serializable]

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ private void AttachHandlers()
9393
{
9494
if (GitClient != null)
9595
{
96-
GitClient.CurrentUserChanged+=GitClientOnCurrentUserChanged;
96+
GitClient.CurrentUserChanged += GitClientOnCurrentUserChanged;
9797
}
9898
}
9999

@@ -124,9 +124,10 @@ private void MaybeUpdateData()
124124
if (userHasChanges)
125125
{
126126
userHasChanges = false;
127+
var currentUser = GitClient.CurrentUser;
128+
isUserDataPresent = !string.IsNullOrEmpty(currentUser.Name)
129+
&& !string.IsNullOrEmpty(currentUser.Email);
127130
hasCompletedInitialCheck = true;
128-
isUserDataPresent = !string.IsNullOrEmpty(GitClient.CurrentUser.Name)
129-
&& !string.IsNullOrEmpty(GitClient.CurrentUser.Email);
130131
}
131132
}
132133

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,14 @@ private void AttachHandlers()
9898

9999
private void GitClientOnCurrentUserChanged(CacheUpdateEvent cacheUpdateEvent)
100100
{
101+
Logger.Trace("GitClientOnCurrentUserChanged");
102+
101103
if (!lastCheckUserChangedEvent.Equals(cacheUpdateEvent))
102104
{
103-
new ActionTask(TaskManager.Token, () =>
104-
{
105+
new ActionTask(TaskManager.Token, () => {
105106
lastCheckUserChangedEvent = cacheUpdateEvent;
106107
userHasChanges = true;
108+
isBusy = false;
107109
Redraw();
108110
})
109111
{ Affinity = TaskAffinity.UI }.Start();
@@ -123,8 +125,9 @@ private void MaybeUpdateData()
123125
if (userHasChanges)
124126
{
125127
userHasChanges = false;
126-
gitName = newGitName = GitClient.CurrentUser.Name;
127-
gitEmail = newGitEmail = GitClient.CurrentUser.Email;
128+
var currentUser = GitClient.CurrentUser;
129+
gitName = newGitName = currentUser.Name;
130+
gitEmail = newGitEmail = currentUser.Email;
128131
}
129132
}
130133

0 commit comments

Comments
 (0)