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

Commit 52f315c

Browse files
Adding an optimization to usages of cache manager
1 parent 95613fe commit 52f315c

File tree

6 files changed

+61
-16
lines changed

6 files changed

+61
-16
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,16 @@ public override void InitializeView(IView parent)
6262

6363
private void Repository_BranchCacheUpdated(CacheUpdateEvent cacheUpdateEvent)
6464
{
65-
new ActionTask(TaskManager.Token, () => {
65+
if (!branchUpdateEvent.Equals(cacheUpdateEvent))
66+
{
67+
new ActionTask(TaskManager.Token, () =>
68+
{
6669
branchUpdateEvent = cacheUpdateEvent;
6770
branchCacheHasUpdate = true;
6871
Redraw();
6972
})
7073
{ Affinity = TaskAffinity.UI }.Start();
74+
}
7175
}
7276

7377
public override void OnEnable()

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,30 @@ public override void InitializeView(IView parent)
3939

4040
private void Repository_GitStatusCacheUpdated(CacheUpdateEvent cacheUpdateEvent)
4141
{
42-
new ActionTask(TaskManager.Token, () => {
42+
if (!gitStatusUpdateEvent.Equals(cacheUpdateEvent))
43+
{
44+
new ActionTask(TaskManager.Token, () =>
45+
{
4346
gitStatusUpdateEvent = cacheUpdateEvent;
4447
gitStatusCacheHasUpdate = true;
4548
Redraw();
4649
})
4750
{ Affinity = TaskAffinity.UI }.Start();
51+
}
4852
}
4953

5054
private void Repository_BranchCacheUpdated(CacheUpdateEvent cacheUpdateEvent)
5155
{
52-
new ActionTask(TaskManager.Token, () => {
56+
if (!branchUpdateEvent.Equals(cacheUpdateEvent))
57+
{
58+
new ActionTask(TaskManager.Token, () =>
59+
{
5360
branchUpdateEvent = cacheUpdateEvent;
5461
branchCacheHasUpdate = true;
5562
Redraw();
5663
})
5764
{ Affinity = TaskAffinity.UI }.Start();
65+
}
5866
}
5967

6068
private void AttachHandlers(IRepository repository)

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,32 +102,44 @@ public override void OnGUI()
102102

103103
private void Repository_GitStatusCacheUpdated(CacheUpdateEvent cacheUpdateEvent)
104104
{
105-
new ActionTask(TaskManager.Token, () => {
105+
if (!gitStatusUpdateEvent.Equals(cacheUpdateEvent))
106+
{
107+
new ActionTask(TaskManager.Token, () =>
108+
{
106109
gitStatusUpdateEvent = cacheUpdateEvent;
107110
gitStatusCacheHasUpdate = true;
108111
Redraw();
109112
})
110113
{ Affinity = TaskAffinity.UI }.Start();
114+
}
111115
}
112116

113117
private void Repository_GitLogCacheUpdated(CacheUpdateEvent cacheUpdateEvent)
114118
{
115-
new ActionTask(TaskManager.Token, () => {
119+
if (!gitLogCacheUpdateEvent.Equals(cacheUpdateEvent))
120+
{
121+
new ActionTask(TaskManager.Token, () =>
122+
{
116123
gitLogCacheUpdateEvent = cacheUpdateEvent;
117124
gitLogCacheHasUpdate = true;
118125
Redraw();
119126
})
120127
{ Affinity = TaskAffinity.UI }.Start();
128+
}
121129
}
122130

123131
private void Repository_BranchCacheUpdated(CacheUpdateEvent cacheUpdateEvent)
124132
{
125-
new ActionTask(TaskManager.Token, () => {
133+
if (!branchUpdateEvent.Equals(cacheUpdateEvent))
134+
{
135+
new ActionTask(TaskManager.Token, () =>
136+
{
126137
branchUpdateEvent = cacheUpdateEvent;
127138
branchCacheHasUpdate = true;
128139
Redraw();
129140
})
130141
{ Affinity = TaskAffinity.UI }.Start();
142+
}
131143
}
132144

133145
private void AttachHandlers(IRepository repository)

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,20 +45,28 @@ public static void Initialize(IRepository repo)
4545

4646
private static void Repository_GitStatusCacheUpdated(CacheUpdateEvent cacheUpdateEvent)
4747
{
48-
new ActionTask(CancellationToken.None, () => {
48+
if (!gitStatusUpdateEvent.Equals(cacheUpdateEvent))
49+
{
50+
new ActionTask(CancellationToken.None, () =>
51+
{
4952
gitStatusUpdateEvent = cacheUpdateEvent;
5053
OnStatusUpdate(repository.CurrentStatus);
5154
})
5255
{ Affinity = TaskAffinity.UI }.Start();
56+
}
5357
}
5458

5559
private static void Repository_GitLockCacheUpdated(CacheUpdateEvent cacheUpdateEvent)
5660
{
57-
new ActionTask(CancellationToken.None, () => {
58-
gitLocksUpdateEvent = cacheUpdateEvent;
61+
if (!gitStatusUpdateEvent.Equals(cacheUpdateEvent))
62+
{
63+
new ActionTask(CancellationToken.None, () =>
64+
{
65+
gitStatusUpdateEvent = cacheUpdateEvent;
5966
OnLocksUpdate(repository.CurrentLocks);
6067
})
6168
{ Affinity = TaskAffinity.UI }.Start();
69+
}
6270
}
6371

6472
[MenuItem("Assets/Request Lock", true)]

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,22 +109,30 @@ private void AttachHandlers(IRepository repository)
109109

110110
private void Repository_GitLockCacheUpdated(CacheUpdateEvent cacheUpdateEvent)
111111
{
112-
new ActionTask(TaskManager.Token, () => {
112+
if (!gitLocksUpdateEvent.Equals(cacheUpdateEvent))
113+
{
114+
new ActionTask(TaskManager.Token, () =>
115+
{
113116
gitLocksUpdateEvent = cacheUpdateEvent;
114117
gitLocksCacheHasUpdate = true;
115118
Redraw();
116119
})
117120
{ Affinity = TaskAffinity.UI }.Start();
121+
}
118122
}
119123

120124
private void Repository_BranchCacheUpdated(CacheUpdateEvent cacheUpdateEvent)
121125
{
122-
new ActionTask(TaskManager.Token, () => {
126+
if (!branchUpdateEvent.Equals(cacheUpdateEvent))
127+
{
128+
new ActionTask(TaskManager.Token, () =>
129+
{
123130
branchUpdateEvent = cacheUpdateEvent;
124131
branchCacheHasUpdate = true;
125132
Redraw();
126133
})
127134
{ Affinity = TaskAffinity.UI }.Start();
135+
}
128136
}
129137

130138
private void DetachHandlers(IRepository repository)

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -275,11 +275,16 @@ private void AttachHandlers(IRepository repository)
275275

276276
private void Repository_RepositoryInfoCacheUpdated(CacheUpdateEvent cacheUpdateEvent)
277277
{
278-
new ActionTask(TaskManager.Token, () => {
279-
repositoryInfoUpdateEvent = cacheUpdateEvent;
280-
repositoryInfoCacheHasUpdate = true;
281-
Redraw();
282-
}) { Affinity = TaskAffinity.UI }.Start();
278+
if (!repositoryInfoUpdateEvent.Equals(cacheUpdateEvent))
279+
{
280+
new ActionTask(TaskManager.Token, () =>
281+
{
282+
repositoryInfoUpdateEvent = cacheUpdateEvent;
283+
repositoryInfoCacheHasUpdate = true;
284+
Redraw();
285+
})
286+
{ Affinity = TaskAffinity.UI }.Start();
287+
}
283288
}
284289

285290
private void DetachHandlers(IRepository repository)

0 commit comments

Comments
 (0)