From e3860e35e34580ac3d833996bc5dac23d9a8f8b4 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Sat, 19 Sep 2020 02:32:51 -0400 Subject: [PATCH] Refreshes line annotations when auth changes --- src/annotations/lineAnnotationController.ts | 3 ++- src/git/remotes/provider.ts | 13 +++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/annotations/lineAnnotationController.ts b/src/annotations/lineAnnotationController.ts index a278b11..e164eae 100644 --- a/src/annotations/lineAnnotationController.ts +++ b/src/annotations/lineAnnotationController.ts @@ -13,7 +13,7 @@ import { Annotations } from './annotations'; import { configuration } from '../configuration'; import { GlyphChars, isTextEditor } from '../constants'; import { Container } from '../container'; -import { CommitFormatter, GitBlameCommit, PullRequest } from '../git/git'; +import { Authentication, CommitFormatter, GitBlameCommit, PullRequest } from '../git/git'; import { LogCorrelationContext, Logger } from '../logger'; import { debug, Iterables, log, Promises } from '../system'; import { LinesChangeEvent, LineSelection } from '../trackers/gitLineTracker'; @@ -35,6 +35,7 @@ export class LineAnnotationController implements Disposable { this._disposable = Disposable.from( configuration.onDidChange(this.onConfigurationChanged, this), Container.fileAnnotations.onDidToggleAnnotations(this.onFileAnnotationsToggled, this), + Authentication.onDidChange(() => void this.refresh(window.activeTextEditor)), ); this.onConfigurationChanged(configuration.initializingChangeEvent); } diff --git a/src/git/remotes/provider.ts b/src/git/remotes/provider.ts index 130a34b..3741c73 100644 --- a/src/git/remotes/provider.ts +++ b/src/git/remotes/provider.ts @@ -21,6 +21,14 @@ import { PullRequest } from '../models/pullRequest'; import { Repository } from '../models/repository'; import { debug, gate, Promises } from '../../system'; +const _onDidChangeAuthentication = new EventEmitter(); + +export class Authentication { + static get onDidChange(): Event { + return _onDidChangeAuthentication.event; + } +} + export class AuthenticationError extends Error { constructor(private original: Error) { super(original.message); @@ -233,8 +241,7 @@ export abstract class RemoteProviderWithApi extends RemoteProvider { private onAuthenticationSessionsChanged(e: AuthenticationSessionsChangeEvent) { if (e.provider.id === this.authProvider.id) { - this._session = null; - this._onDidChange.fire(); + this.disconnect(); } } @@ -254,6 +261,7 @@ export abstract class RemoteProviderWithApi extends RemoteProvider { this.invalidAuthenticationCount = 0; this._session = null; this._onDidChange.fire(); + _onDidChangeAuthentication.fire(); } @gate() @@ -343,6 +351,7 @@ export abstract class RemoteProviderWithApi extends RemoteProvider { if (session != null) { this._onDidChange.fire(); + _onDidChangeAuthentication.fire(); } return session ?? undefined;