Make scopes parameter optional to getSessions and remove getAllSessions

This commit is contained in:
Rachel Macfarlane
2021-02-12 09:05:31 -08:00
parent a16f5d2c4c
commit 14669c2e45
13 changed files with 27 additions and 51 deletions
@@ -24,8 +24,7 @@ export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.authentication.registerAuthenticationProvider('github', 'GitHub', {
onDidChangeSessions: onDidChangeSessions.event,
getAllSessions: () => Promise.resolve(loginService.sessions),
getSessions: (scopes: string[]) => loginService.getSessions(scopes),
getSessions: (scopes?: string[]) => loginService.getSessions(scopes),
createSession: async (scopeList: string[]) => {
try {
/* __GDPR__
@@ -44,8 +44,10 @@ export class GitHubAuthenticationProvider {
context.subscriptions.push(context.secrets.onDidChange(() => this.checkForUpdates()));
}
async getSessions(scopes: string[]): Promise<vscode.AuthenticationSession[]> {
return this._sessions.filter(session => arrayEquals(session.scopes, scopes));
async getSessions(scopes?: string[]): Promise<vscode.AuthenticationSession[]> {
return scopes
? this._sessions.filter(session => arrayEquals(session.scopes, scopes))
: this._sessions;
}
private async verifySessions(): Promise<void> {