@@ -21,18 +21,6 @@ interface SessionData {
2121 accessToken : string ;
2222}
2323
24- // TODO remove
25- interface OldSessionData {
26- id : string ;
27- accountName : string ;
28- scopes : string [ ] ;
29- accessToken : string ;
30- }
31-
32- function isOldSessionData ( x : any ) : x is OldSessionData {
33- return ! ! x . accountName ;
34- }
35-
3624export class GitHubAuthenticationProvider {
3725 private _sessions : vscode . AuthenticationSession2 [ ] = [ ] ;
3826 private _githubServer = new GitHubServer ( ) ;
@@ -96,9 +84,9 @@ export class GitHubAuthenticationProvider {
9684 const storedSessions = await keychain . getToken ( ) ;
9785 if ( storedSessions ) {
9886 try {
99- const sessionData : ( SessionData | OldSessionData ) [ ] = JSON . parse ( storedSessions ) ;
100- const sessionPromises = sessionData . map ( async ( session : SessionData | OldSessionData ) : Promise < vscode . AuthenticationSession2 > => {
101- const needsUserInfo = isOldSessionData ( session ) || ! session . account ;
87+ const sessionData : SessionData [ ] = JSON . parse ( storedSessions ) ;
88+ const sessionPromises = sessionData . map ( async ( session : SessionData ) : Promise < vscode . AuthenticationSession2 > => {
89+ const needsUserInfo = ! session . account ;
10290 let userInfo : { id : string , accountName : string } ;
10391 if ( needsUserInfo ) {
10492 userInfo = await this . _githubServer . getUserInfo ( session . accessToken ) ;
@@ -107,12 +95,8 @@ export class GitHubAuthenticationProvider {
10795 return {
10896 id : session . id ,
10997 account : {
110- displayName : isOldSessionData ( session )
111- ? session . accountName
112- : session . account ?. displayName ?? userInfo ! . accountName ,
113- id : isOldSessionData ( session )
114- ? userInfo ! . id
115- : session . account ?. id ?? userInfo ! . id
98+ displayName : session . account ?. displayName ?? userInfo ! . accountName ,
99+ id : session . account ?. id ?? userInfo ! . id
116100 } ,
117101 scopes : session . scopes ,
118102 accessToken : session . accessToken
0 commit comments