Polish onDidChangePassword changes

This commit is contained in:
Rachel Macfarlane
2020-10-12 10:31:00 -07:00
parent 9910c38005
commit 31419adc34
9 changed files with 15 additions and 22 deletions

View File

@@ -84,12 +84,6 @@ export class Keychain {
return Promise.resolve(undefined);
}
}
onDidChangePassword(listener: () => void) {
vscode.authentication.onDidChangePassword(_ => {
listener();
});
}
}
export const keychain = new Keychain();

View File

@@ -16,7 +16,7 @@ export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.window.registerUriHandler(uriHandler));
const loginService = new GitHubAuthenticationProvider();
await loginService.initialize();
await loginService.initialize(context);
context.subscriptions.push(vscode.commands.registerCommand('github.provide-token', () => {
return loginService.manuallyProvideToken();

View File

@@ -26,14 +26,14 @@ export class GitHubAuthenticationProvider {
private _sessions: vscode.AuthenticationSession[] = [];
private _githubServer = new GitHubServer();
public async initialize(): Promise<void> {
public async initialize(context: vscode.ExtensionContext): Promise<void> {
try {
this._sessions = await this.readSessions();
} catch (e) {
// Ignore, network request failed
}
keychain.onDidChangePassword(() => this.checkForUpdates());
context.subscriptions.push(vscode.authentication.onDidChangePassword(() => this.checkForUpdates()));
}
private async checkForUpdates() {