@@ -24,22 +24,37 @@ export async function newSession(forceMessage: string): Promise<vscode.Authentic
2424 * Retrieves a session from the GitHub authentication provider or prompts the user to sign in
2525 * @returns A {@link vscode.AuthenticationSession} or undefined
2626 */
27- export async function getSession ( ) : Promise < vscode . AuthenticationSession | undefined > {
28- const session = await getSessionInternal ( false ) ;
29- if ( session || signInPrompted ) {
27+ export async function getSession ( skipPrompt = false ) : Promise < vscode . AuthenticationSession | undefined > {
28+ const session = await getSessionInternal ( skipPrompt ) ;
29+ if ( session ) {
30+ await vscode . commands . executeCommand ( "setContext" , "github-actions.signed-in" , true ) ;
3031 return session ;
3132 }
3233
34+ if ( signInPrompted || skipPrompt ) {
35+ return undefined ;
36+ }
37+
3338 signInPrompted = true ;
3439 const signInAction = "Sign in to GitHub" ;
35- const result = await vscode . window . showInformationMessage (
36- "Sign in to GitHub to access your repositories and GitHub Actions workflows." ,
37- signInAction
38- ) ;
39- if ( result === signInAction ) {
40- return await getSessionInternal ( true ) ;
41- }
42- throw new Error ( SESSION_ERROR ) ;
40+ vscode . window
41+ . showInformationMessage ( "Sign in to GitHub to access your repositories and GitHub Actions workflows." , signInAction )
42+ . then (
43+ async result => {
44+ if ( result === signInAction ) {
45+ const session = await getSessionInternal ( true ) ;
46+ if ( session ) {
47+ await vscode . commands . executeCommand ( "setContext" , "github-actions.signed-in" , true ) ;
48+ }
49+ }
50+ } ,
51+ ( ) => {
52+ // Ignore rejected promise
53+ }
54+ ) ;
55+
56+ // User chose to not sign in or hasn't signed in yet
57+ return undefined ;
4358}
4459
4560async function getSessionInternal ( forceNewMessage : string ) : Promise < vscode . AuthenticationSession | undefined > ;
0 commit comments