@@ -25,7 +25,7 @@ namespace GitHub.ViewModels
2525 [ ExportViewModel ( ViewType = UIViewType . PRDetail ) ]
2626 [ PartCreationPolicy ( CreationPolicy . NonShared ) ]
2727 [ NullGuard ( ValidationFlags . None ) ]
28- public class PullRequestDetailViewModel : PanePageViewModelBase , IPullRequestDetailViewModel , IHasBusy
28+ public class PullRequestDetailViewModel : PanePageViewModelBase , IPullRequestDetailViewModel
2929 {
3030 readonly ILocalRepositoryModel repository ;
3131 readonly IModelService modelService ;
@@ -35,10 +35,12 @@ public class PullRequestDetailViewModel : PanePageViewModelBase, IPullRequestDet
3535 string sourceBranchDisplayName ;
3636 string targetBranchDisplayName ;
3737 string body ;
38+ IReadOnlyList < IPullRequestChangeNode > changedFilesTree ;
3839 IPullRequestCheckoutState checkoutState ;
3940 IPullRequestUpdateState updateState ;
4041 string operationError ;
4142 bool isBusy ;
43+ bool isLoading ;
4244 bool isCheckedOut ;
4345 bool isFromFork ;
4446 bool isInCheckout ;
@@ -147,7 +149,7 @@ public string TargetBranchDisplayName
147149 }
148150
149151 /// <summary>
150- /// Gets a value indicating whether the view model is loading .
152+ /// Gets a value indicating whether the view model is updating .
151153 /// </summary>
152154 public bool IsBusy
153155 {
@@ -163,6 +165,15 @@ public bool IsCheckedOut
163165 private set { this . RaiseAndSetIfChanged ( ref isCheckedOut , value ) ; }
164166 }
165167
168+ /// <summary>
169+ /// Gets a value indicating whether the view model is loading.
170+ /// </summary>
171+ public bool IsLoading
172+ {
173+ get { return isLoading ; }
174+ private set { this . RaiseAndSetIfChanged ( ref isLoading , value ) ; }
175+ }
176+
166177 /// <summary>
167178 /// Gets a value indicating whether the pull request comes from a fork.
168179 /// </summary>
@@ -212,7 +223,11 @@ public string OperationError
212223 /// <summary>
213224 /// Gets the changed files as a tree.
214225 /// </summary>
215- public IReactiveList < IPullRequestChangeNode > ChangedFilesTree { get ; } = new ReactiveList < IPullRequestChangeNode > ( ) ;
226+ public IReadOnlyList < IPullRequestChangeNode > ChangedFilesTree
227+ {
228+ get { return changedFilesTree ; }
229+ private set { this . RaiseAndSetIfChanged ( ref changedFilesTree , value ) ; }
230+ }
216231
217232 /// <summary>
218233 /// Gets a command that checks out the pull request locally.
@@ -252,7 +267,10 @@ public override void Initialize([AllowNull] ViewWithData data)
252267 {
253268 var prNumber = data ? . Data != null ? ( int ) data . Data : Model . Number ;
254269
255- IsBusy = true ;
270+ if ( Model == null )
271+ IsLoading = true ;
272+ else
273+ IsBusy = true ;
256274
257275 OperationError = null ;
258276 modelService . GetPullRequest ( repository , prNumber )
@@ -276,15 +294,8 @@ public async Task Load(IPullRequestModel pullRequest)
276294 TargetBranchDisplayName = GetBranchDisplayName ( IsFromFork , pullRequest . Base . Label ) ;
277295 Body = ! string . IsNullOrWhiteSpace ( pullRequest . Body ) ? pullRequest . Body : Resources . NoDescriptionProvidedMarkdown ;
278296
279- ChangedFilesTree . Clear ( ) ;
280-
281- var treeChanges = await pullRequestsService . GetTreeChanges ( repository , pullRequest ) ;
282-
283- // WPF doesn't support AddRange here so iterate through the changes.
284- foreach ( var change in CreateChangedFilesTree ( pullRequest , treeChanges ) . Children )
285- {
286- ChangedFilesTree . Add ( change ) ;
287- }
297+ var changes = await pullRequestsService . GetTreeChanges ( repository , pullRequest ) ;
298+ ChangedFilesTree = CreateChangedFilesTree ( pullRequest , changes ) . Children . ToList ( ) ;
288299
289300 var localBranches = await pullRequestsService . GetLocalBranches ( repository , pullRequest ) . ToList ( ) ;
290301
@@ -350,7 +361,7 @@ public async Task Load(IPullRequestModel pullRequest)
350361 UpdateState = null ;
351362 }
352363
353- IsBusy = false ;
364+ IsLoading = IsBusy = false ;
354365
355366 if ( ! isInCheckout )
356367 {
0 commit comments