Skip to content

Commit 34c1a34

Browse files
Merge pull request #97 from github/lrotschyketchup/fixContextsForViewSimple
Set all contexts for view upon sign in
2 parents a1b382a + c1de3ce commit 34c1a34

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/commands/signIn.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,20 @@
11
import * as vscode from "vscode";
22
import {getSession} from "../auth/auth";
3+
import {canReachGitHubAPI} from "../api/canReachGitHubAPI";
4+
import {getGitHubContext} from "../git/repository";
35

46
export function registerSignIn(context: vscode.ExtensionContext) {
57
context.subscriptions.push(
68
vscode.commands.registerCommand("github-actions.sign-in", async () => {
79
const session = await getSession(true);
810
if (session) {
11+
const canReachAPI = await canReachGitHubAPI();
12+
const ghContext = await getGitHubContext();
13+
const hasGitHubRepos = ghContext && ghContext.repos.length > 0;
14+
915
await vscode.commands.executeCommand("setContext", "github-actions.signed-in", true);
16+
await vscode.commands.executeCommand("setContext", "github-actions.internet-access", canReachAPI);
17+
await vscode.commands.executeCommand("setContext", "github-actions.has-repos", hasGitHubRepos);
1018
}
1119
})
1220
);

src/treeViews/treeViews.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,12 @@ export async function initTreeViews(context: vscode.ExtensionContext, store: Run
2525
vscode.commands.registerCommand("github-actions.explorer.refresh", async () => {
2626
const canReachAPI = await canReachGitHubAPI();
2727
await vscode.commands.executeCommand("setContext", "github-actions.internet-access", canReachAPI);
28-
if (canReachAPI) {
28+
29+
const ghContext = await getGitHubContext();
30+
const hasGitHubRepos = ghContext && ghContext.repos.length > 0;
31+
await vscode.commands.executeCommand("setContext", "github-actions.has-repos", hasGitHubRepos);
32+
33+
if (canReachAPI && hasGitHubRepos) {
2934
await workflowTreeProvider.refresh();
3035
await settingsTreeProvider.refresh();
3136
}

0 commit comments

Comments
 (0)