Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/GitHub.TeamFoundation.14/Base/EnsureLoggedInSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async Task CheckLogin()
if (ActiveRepo == null || ActiveRepoUri == null)
return;

var isgithub = await IsAGitHubRepo();
var isgithub = await IsAGitHubRepo(ActiveRepoUri);
if (!isgithub)
return;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
using System;
using System.Diagnostics;
using System.Drawing;
using System.Threading.Tasks;
using GitHub.Api;
using GitHub.Extensions;
using GitHub.Logging;
using GitHub.Services;
using GitHub.UI;
using GitHub.VisualStudio.Helpers;
using Microsoft.TeamFoundation.Controls;
using Microsoft.VisualStudio.PlatformUI;
using Serilog;

namespace GitHub.VisualStudio.Base
{
public class TeamExplorerNavigationItemBase : TeamExplorerItemBase, ITeamExplorerNavigationItem2
{
static readonly ILogger log = LogManager.ForContext<TeamExplorerNavigationItemBase>();

readonly Octicon octicon;

public TeamExplorerNavigationItemBase(IGitHubServiceProvider serviceProvider,
Expand All @@ -35,10 +40,23 @@ public TeamExplorerNavigationItemBase(IGitHubServiceProvider serviceProvider,
SubscribeToRepoChanges();
}

public override async void Invalidate()
public override void Invalidate()
{
IsVisible = false;
IsVisible = await IsAGitHubRepo();
InvalidateAsync().Forget(log);
}

async Task InvalidateAsync()
{
var uri = ActiveRepoUri;
var isVisible = await IsAGitHubRepo(uri);
if (ActiveRepoUri != uri)
{
log.Information("Not setting button visibility because repository changed from {BeforeUrl} to {AfterUrl}", uri, ActiveRepoUri);
return;
}

IsVisible = isVisible;
}

void OnThemeChanged()
Expand Down
2 changes: 1 addition & 1 deletion src/GitHub.TeamFoundation.14/Home/ForkNavigationItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public override async void Invalidate()
{
IsVisible = false;

if (await IsAGitHubDotComRepo())
if (await IsAGitHubDotComRepo(ActiveRepoUri))
{
var connection = await ConnectionManager.GetConnection(ActiveRepo);
IsVisible = connection?.IsLoggedIn ?? false;
Expand Down
4 changes: 2 additions & 2 deletions src/GitHub.TeamFoundation.14/Home/GitHubHomeSection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ protected async override void RepoChanged()

base.RepoChanged();

IsVisible = await IsAGitHubRepo();
IsVisible = await IsAGitHubRepo(ActiveRepoUri);

if (IsVisible)
{
Expand Down Expand Up @@ -93,7 +93,7 @@ protected async override void RepoChanged()

public override async void Refresh()
{
IsVisible = await IsAGitHubRepo();
IsVisible = await IsAGitHubRepo(ActiveRepoUri);
if (IsVisible)
{
IsLoggedIn = await IsUserAuthenticated();
Expand Down
2 changes: 1 addition & 1 deletion src/GitHub.TeamFoundation.14/Home/IssuesNavigationItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public override async void Invalidate()
{
IsVisible = false;

var visible = await IsAGitHubRepo();
var visible = await IsAGitHubRepo(ActiveRepoUri);
if (visible)
{
var repo = await SimpleApiClient.GetRepository();
Expand Down
2 changes: 1 addition & 1 deletion src/GitHub.TeamFoundation.14/Home/WikiNavigationItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override void Execute()

public override async void Invalidate()
{
var visible = await IsAGitHubRepo();
var visible = await IsAGitHubRepo(ActiveRepoUri);
if (visible)
{
var repo = await SimpleApiClient.GetRepository();
Expand Down
14 changes: 5 additions & 9 deletions src/GitHub.VisualStudio.UI/Base/TeamExplorerItemBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,8 @@ protected virtual void RepoChanged()
}
}

protected async Task<RepositoryOrigin> GetRepositoryOrigin()
protected async Task<RepositoryOrigin> GetRepositoryOrigin(UriString uri)
{
if (ActiveRepo == null)
return RepositoryOrigin.NonGitRepository;

var uri = ActiveRepoUri;
if (uri == null)
return RepositoryOrigin.Other;

Expand All @@ -154,15 +150,15 @@ protected async Task<RepositoryOrigin> GetRepositoryOrigin()
return RepositoryOrigin.Other;
}

protected async Task<bool> IsAGitHubRepo()
protected async Task<bool> IsAGitHubRepo(UriString uri)
{
var origin = await GetRepositoryOrigin();
var origin = await GetRepositoryOrigin(uri);
return origin == RepositoryOrigin.DotCom || origin == RepositoryOrigin.Enterprise;
}

protected async Task<bool> IsAGitHubDotComRepo()
protected async Task<bool> IsAGitHubDotComRepo(UriString uri)
{
var origin = await GetRepositoryOrigin();
var origin = await GetRepositoryOrigin(uri);
return origin == RepositoryOrigin.DotCom;
}

Expand Down