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

Commit 29b0536

Browse files
authored
Merge pull request #1359 from github/fixes/1345-refresh-PR-detail-view
Lightweight fix for PR detail view not refreshing
2 parents e13678c + 81e29d3 commit 29b0536

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

src/GitHub.App/ViewModels/PullRequestDetailViewModel.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ namespace GitHub.ViewModels
2626
/// </summary>
2727
[ExportViewModel(ViewType = UIViewType.PRDetail)]
2828
[PartCreationPolicy(CreationPolicy.NonShared)]
29-
public class PullRequestDetailViewModel : PanePageViewModelBase, IPullRequestDetailViewModel
29+
public sealed class PullRequestDetailViewModel : PanePageViewModelBase, IPullRequestDetailViewModel, IDisposable
3030
{
3131
static readonly ILogger log = LogManager.ForContext<PullRequestDetailViewModel>();
3232

3333
readonly IModelService modelService;
3434
readonly IPullRequestService pullRequestsService;
3535
readonly IPullRequestSessionManager sessionManager;
3636
readonly IUsageTracker usageTracker;
37+
readonly IVSGitExt vsGitExt;
3738
IPullRequestModel model;
3839
string sourceBranchDisplayName;
3940
string targetBranchDisplayName;
@@ -65,13 +66,22 @@ public class PullRequestDetailViewModel : PanePageViewModelBase, IPullRequestDet
6566
ITeamExplorerServiceHolder teservice,
6667
IPullRequestService pullRequestsService,
6768
IPullRequestSessionManager sessionManager,
68-
IUsageTracker usageTracker)
69+
IUsageTracker usageTracker,
70+
IVSGitExt vsGitExt)
6971
: this(teservice.ActiveRepo,
7072
modelServiceFactory.CreateBlocking(connection.Get()),
7173
pullRequestsService,
7274
sessionManager,
7375
usageTracker)
7476
{
77+
this.vsGitExt = vsGitExt;
78+
79+
vsGitExt.ActiveRepositoriesChanged += Refresh;
80+
}
81+
82+
public void Dispose()
83+
{
84+
vsGitExt.ActiveRepositoriesChanged -= Refresh;
7585
}
7686

7787
/// <summary>
@@ -502,6 +512,18 @@ public string GetLocalFilePath(IPullRequestFileNode file)
502512
return Path.Combine(LocalRepository.LocalPath, file.DirectoryPath, file.FileName);
503513
}
504514

515+
async void Refresh()
516+
{
517+
try
518+
{
519+
await Load(RemoteRepositoryOwner, Model);
520+
}
521+
catch (Exception e)
522+
{
523+
log.Error(e, "Error refreshing model");
524+
}
525+
}
526+
505527
void SubscribeOperationError(ReactiveCommand<Unit> command)
506528
{
507529
command.ThrownExceptions.Subscribe(x => OperationError = x.Message);

0 commit comments

Comments
 (0)