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

Commit acf2213

Browse files
committed
Use UIContext_Git to initialize PR status bar
We no longer need to use `IVSGitExt` to initialize the PR status bar when there is an active Git repository.
1 parent ddbec51 commit acf2213

File tree

2 files changed

+8
-19
lines changed

2 files changed

+8
-19
lines changed

src/GitHub.InlineReviews/PullRequestStatusBarPackage.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Threading;
33
using System.Runtime.InteropServices;
4+
using GitHub.Helpers;
45
using GitHub.Services;
56
using GitHub.VisualStudio;
67
using GitHub.InlineReviews.Services;
@@ -11,7 +12,7 @@ namespace GitHub.InlineReviews
1112
{
1213
[Guid(Guids.PullRequestStatusPackageId)]
1314
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
14-
[ProvideAutoLoad(Guids.GitSccProviderId, PackageAutoLoadFlags.BackgroundLoad)]
15+
[ProvideAutoLoad(Guids.UIContext_Git, PackageAutoLoadFlags.BackgroundLoad)]
1516
public class PullRequestStatusBarPackage : AsyncPackage
1617
{
1718
/// <summary>
@@ -21,9 +22,11 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
2122
{
2223
var usageTracker = (IUsageTracker)await GetServiceAsync(typeof(IUsageTracker));
2324
var serviceProvider = (IGitHubServiceProvider)await GetServiceAsync(typeof(IGitHubServiceProvider));
24-
var gitExt = (IVSGitExt)await GetServiceAsync(typeof(IVSGitExt));
25+
var barManager = new PullRequestStatusBarManager(usageTracker, serviceProvider);
2526

26-
new PullRequestStatusBarManager(gitExt, usageTracker, serviceProvider);
27+
// await ThreadingHelper.SwitchToMainThreadAsync() won't return until after a solution
28+
// has been loaded. We're using the following instead as a workaround.
29+
await ThreadingHelper.MainThreadDispatcher.InvokeAsync(() => barManager.StartShowingStatus());
2730
}
2831
}
2932
}

src/GitHub.InlineReviews/Services/PullRequestStatusBarManager.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,33 +21,19 @@ public class PullRequestStatusBarManager
2121
static readonly ILogger log = LogManager.ForContext<PullRequestStatusBarManager>();
2222
const string StatusBarPartName = "PART_SccStatusBarHost";
2323

24-
readonly IVSGitExt gitExt;
2524
readonly IUsageTracker usageTracker;
2625
readonly IGitHubServiceProvider serviceProvider;
2726

2827
IPullRequestSessionManager pullRequestSessionManager;
2928

3029
[ImportingConstructor]
31-
public PullRequestStatusBarManager(IVSGitExt gitExt, IUsageTracker usageTracker, IGitHubServiceProvider serviceProvider)
30+
public PullRequestStatusBarManager(IUsageTracker usageTracker, IGitHubServiceProvider serviceProvider)
3231
{
33-
this.gitExt = gitExt;
3432
this.usageTracker = usageTracker;
3533
this.serviceProvider = serviceProvider;
36-
37-
OnActiveRepositoriesChanged();
38-
gitExt.ActiveRepositoriesChanged += OnActiveRepositoriesChanged;
39-
}
40-
41-
void OnActiveRepositoriesChanged()
42-
{
43-
if (gitExt.ActiveRepositories.Count > 0)
44-
{
45-
gitExt.ActiveRepositoriesChanged -= OnActiveRepositoriesChanged;
46-
Application.Current.Dispatcher.Invoke(() => StartShowingStatus());
47-
}
4834
}
4935

50-
void StartShowingStatus()
36+
public void StartShowingStatus()
5137
{
5238
try
5339
{

0 commit comments

Comments
 (0)