Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 68fd076

Browse files
committed
Merge branch 'master' into refactor/mvvm
Conflicts: src/GitHub.App/ViewModels/GitHubPane/PullRequestDetailViewModel.cs
2 parents b93c6f9 + 29b0536 commit 68fd076

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

src/GitHub.App/ViewModels/GitHubPane/PullRequestDetailViewModel.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@ namespace GitHub.ViewModels.GitHubPane
2424
/// </summary>
2525
[Export(typeof(IPullRequestDetailViewModel))]
2626
[PartCreationPolicy(CreationPolicy.NonShared)]
27-
public class PullRequestDetailViewModel : PanePageViewModelBase, IPullRequestDetailViewModel
27+
public sealed class PullRequestDetailViewModel : PanePageViewModelBase, IPullRequestDetailViewModel
2828
{
2929
static readonly ILogger log = LogManager.ForContext<PullRequestDetailViewModel>();
3030

3131
readonly IModelServiceFactory modelServiceFactory;
3232
readonly IPullRequestService pullRequestsService;
3333
readonly IPullRequestSessionManager sessionManager;
3434
readonly IUsageTracker usageTracker;
35+
readonly IVSGitExt vsGitExt;
3536
IModelService modelService;
3637
IPullRequestModel model;
3738
string sourceBranchDisplayName;
@@ -55,12 +56,14 @@ public class PullRequestDetailViewModel : PanePageViewModelBase, IPullRequestDet
5556
/// <param name="pullRequestsService">The pull requests service.</param>
5657
/// <param name="sessionManager">The pull request session manager.</param>
5758
/// <param name="usageTracker">The usage tracker.</param>
59+
/// <param name="vsGitExt">The Visual Studio git service.</param>
5860
[ImportingConstructor]
5961
public PullRequestDetailViewModel(
6062
IPullRequestService pullRequestsService,
6163
IPullRequestSessionManager sessionManager,
6264
IModelServiceFactory modelServiceFactory,
63-
IUsageTracker usageTracker)
65+
IUsageTracker usageTracker,
66+
IVSGitExt vsGitExt)
6467
{
6568
Guard.ArgumentNotNull(pullRequestsService, nameof(pullRequestsService));
6669
Guard.ArgumentNotNull(sessionManager, nameof(sessionManager));
@@ -71,6 +74,7 @@ public PullRequestDetailViewModel(
7174
this.sessionManager = sessionManager;
7275
this.modelServiceFactory = modelServiceFactory;
7376
this.usageTracker = usageTracker;
77+
this.vsGitExt = vsGitExt;
7478

7579
Checkout = ReactiveCommand.CreateAsyncObservable(
7680
this.WhenAnyValue(x => x.CheckoutState)
@@ -98,7 +102,7 @@ public PullRequestDetailViewModel(
98102
DiffFile = ReactiveCommand.Create();
99103
DiffFileWithWorkingDirectory = ReactiveCommand.Create(this.WhenAnyValue(x => x.IsCheckedOut));
100104
OpenFileInWorkingDirectory = ReactiveCommand.Create(this.WhenAnyValue(x => x.IsCheckedOut));
101-
ViewFile = ReactiveCommand.Create();
105+
ViewFile = ReactiveCommand.Create();
102106
}
103107

104108
/// <summary>
@@ -314,6 +318,7 @@ public async Task InitializeAsync(
314318
Number = number;
315319
WebUrl = LocalRepository.CloneUrl.ToRepositoryUrl().Append("pull/" + number);
316320
modelService = await modelServiceFactory.CreateAsync(connection);
321+
vsGitExt.ActiveRepositoriesChanged += ActiveRepositoriesChanged;
317322
await Refresh();
318323
}
319324
finally
@@ -477,6 +482,19 @@ public string GetLocalFilePath(IPullRequestFileNode file)
477482
return Path.Combine(LocalRepository.LocalPath, file.DirectoryPath, file.FileName);
478483
}
479484

485+
/// <inheritdoc/>
486+
protected override void Dispose(bool disposing)
487+
{
488+
base.Dispose(disposing);
489+
490+
if (disposing)
491+
{
492+
vsGitExt.ActiveRepositoriesChanged -= ActiveRepositoriesChanged;
493+
}
494+
}
495+
496+
void ActiveRepositoriesChanged() => Refresh().Forget();
497+
480498
void SubscribeOperationError(ReactiveCommand<Unit> command)
481499
{
482500
command.ThrownExceptions.Subscribe(x => OperationError = x.Message);

0 commit comments

Comments
 (0)