|
2 | 2 | using System.Collections;
|
3 | 3 | using System.Collections.Generic;
|
4 | 4 | using System.IO;
|
| 5 | +using System.Threading.Tasks; |
5 | 6 |
|
6 | 7 | using Avalonia.Controls;
|
| 8 | +using Avalonia.Threading; |
7 | 9 | using CommunityToolkit.Mvvm.ComponentModel;
|
8 | 10 |
|
9 | 11 | namespace SourceGit.ViewModels
|
@@ -133,34 +135,20 @@ public Models.BisectState UpdateBisectInfo()
|
133 | 135 | public void NavigateTo(string commitSHA)
|
134 | 136 | {
|
135 | 137 | var commit = _commits.Find(x => x.SHA.StartsWith(commitSHA, StringComparison.Ordinal));
|
136 |
| - if (commit == null) |
137 |
| - { |
138 |
| - AutoSelectedCommit = null; |
139 |
| - commit = new Commands.QuerySingleCommit(_repo.FullPath, commitSHA).GetResultAsync().Result; |
140 |
| - } |
141 |
| - else |
142 |
| - { |
143 |
| - AutoSelectedCommit = commit; |
144 |
| - NavigationId = _navigationId + 1; |
145 |
| - } |
146 |
| - |
147 | 138 | if (commit != null)
|
148 | 139 | {
|
149 |
| - if (_detailContext is CommitDetail detail) |
150 |
| - { |
151 |
| - detail.Commit = commit; |
152 |
| - } |
153 |
| - else |
154 |
| - { |
155 |
| - var commitDetail = new CommitDetail(_repo, true); |
156 |
| - commitDetail.Commit = commit; |
157 |
| - DetailContext = commitDetail; |
158 |
| - } |
| 140 | + NavigateTo(commit); |
| 141 | + return; |
159 | 142 | }
|
160 |
| - else |
| 143 | + |
| 144 | + Task.Run(async () => |
161 | 145 | {
|
162 |
| - DetailContext = null; |
163 |
| - } |
| 146 | + var c = await new Commands.QuerySingleCommit(_repo.FullPath, commitSHA) |
| 147 | + .GetResultAsync() |
| 148 | + .ConfigureAwait(false); |
| 149 | + |
| 150 | + Dispatcher.UIThread.Post(() => NavigateTo(c)); |
| 151 | + }); |
164 | 152 | }
|
165 | 153 |
|
166 | 154 | public void Select(IList commits)
|
@@ -297,6 +285,31 @@ public void CheckoutBranchByCommit(Models.Commit commit)
|
297 | 285 | }
|
298 | 286 | }
|
299 | 287 |
|
| 288 | + private void NavigateTo(Models.Commit commit) |
| 289 | + { |
| 290 | + AutoSelectedCommit = commit; |
| 291 | + |
| 292 | + if (commit == null) |
| 293 | + { |
| 294 | + DetailContext = null; |
| 295 | + } |
| 296 | + else |
| 297 | + { |
| 298 | + NavigationId = _navigationId + 1; |
| 299 | + |
| 300 | + if (_detailContext is CommitDetail detail) |
| 301 | + { |
| 302 | + detail.Commit = commit; |
| 303 | + } |
| 304 | + else |
| 305 | + { |
| 306 | + var commitDetail = new CommitDetail(_repo, true); |
| 307 | + commitDetail.Commit = commit; |
| 308 | + DetailContext = commitDetail; |
| 309 | + } |
| 310 | + } |
| 311 | + } |
| 312 | + |
300 | 313 | private Repository _repo = null;
|
301 | 314 | private bool _isLoading = true;
|
302 | 315 | private List<Models.Commit> _commits = new List<Models.Commit>();
|
|
0 commit comments