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

Commit 6f95f8d

Browse files
committed
Defer updates of deactivated PR details.
When a repository change is detected by a non-active `PullRequestDetailViewModel`, set a flag to refresh the view model when it becomes active again.
1 parent 08b0c43 commit 6f95f8d

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.IO;
55
using System.Linq;
66
using System.Reactive;
7+
using System.Reactive.Disposables;
78
using System.Reactive.Linq;
89
using System.Reactive.Threading.Tasks;
910
using System.Threading.Tasks;
@@ -46,6 +47,8 @@ public sealed class PullRequestDetailViewModel : PanePageViewModelBase, IPullReq
4647
bool isCheckedOut;
4748
bool isFromFork;
4849
bool isInCheckout;
50+
bool active;
51+
bool refreshOnActivate;
4952
Uri webUrl;
5053

5154
/// <summary>
@@ -482,6 +485,21 @@ public string GetLocalFilePath(IPullRequestFileNode file)
482485
return Path.Combine(LocalRepository.LocalPath, file.DirectoryPath, file.FileName);
483486
}
484487

488+
/// <inheritdoc/>
489+
public override void Activated()
490+
{
491+
active = true;
492+
493+
if (refreshOnActivate)
494+
{
495+
Refresh().Forget();
496+
refreshOnActivate = false;
497+
}
498+
}
499+
500+
/// <inheritdoc/>
501+
public override void Deactivated() => active = false;
502+
485503
/// <inheritdoc/>
486504
protected override void Dispose(bool disposing)
487505
{
@@ -493,7 +511,17 @@ protected override void Dispose(bool disposing)
493511
}
494512
}
495513

496-
void ActiveRepositoriesChanged() => Refresh().Forget();
514+
void ActiveRepositoriesChanged()
515+
{
516+
if (active)
517+
{
518+
Refresh().Forget();
519+
}
520+
else
521+
{
522+
refreshOnActivate = true;
523+
}
524+
}
497525

498526
void SubscribeOperationError(ReactiveCommand<Unit> command)
499527
{

0 commit comments

Comments
 (0)