diff --git a/src/git/models/repository.ts b/src/git/models/repository.ts index 8fb242c..b240d2a 100644 --- a/src/git/models/repository.ts +++ b/src/git/models/repository.ts @@ -174,6 +174,11 @@ export class Repository implements Disposable { this._disposable?.dispose(); } + private _updatedAt: number = 0; + get updatedAt(): number { + return this._updatedAt; + } + private onConfigurationChanged(e: ConfigurationChangeEvent) { if (configuration.changed(e, 'remotes', this.folder.uri)) { this._providers = RemoteProviderFactory.loadProviders(configuration.get('remotes', this.folder.uri)); @@ -767,6 +772,8 @@ export class Repository implements Disposable { @debug() private fireChange(...changes: RepositoryChange[]) { + this._updatedAt = Date.now(); + if (this._fireChangeDebounced == null) { this._fireChangeDebounced = Functions.debounce(this.fireChangeCore.bind(this), 250); } @@ -806,6 +813,8 @@ export class Repository implements Disposable { @debug() private fireFileSystemChange(uri: Uri) { + this._updatedAt = Date.now(); + if (this._fireFileSystemChangeDebounced == null) { this._fireFileSystemChangeDebounced = Functions.debounce(this.fireFileSystemChangeCore.bind(this), 2500); } diff --git a/src/views/branchesView.ts b/src/views/branchesView.ts index 4e06573..e7057fe 100644 --- a/src/views/branchesView.ts +++ b/src/views/branchesView.ts @@ -100,6 +100,12 @@ export class BranchesRepositoryNode extends SubscribeableViewNode return this.repo.onDidChange(this.onRepositoryChanged, this); } + protected get requiresResetOnVisible(): boolean { + return this._repoUpdatedAt !== this.repo.updatedAt; + } + + private _repoUpdatedAt: number = this.repo.updatedAt; + @debug({ args: { 0: (e: RepositoryChangeEvent) => @@ -107,6 +113,8 @@ export class BranchesRepositoryNode extends SubscribeableViewNode }, }) private onRepositoryChanged(e: RepositoryChangeEvent) { + this._repoUpdatedAt = this.repo.updatedAt; + if (e.changed(RepositoryChange.Closed)) { this.dispose(); void this.parent?.triggerChange(true); diff --git a/src/views/commitsView.ts b/src/views/commitsView.ts index 125a005..5ea35b7 100644 --- a/src/views/commitsView.ts +++ b/src/views/commitsView.ts @@ -129,6 +129,12 @@ export class CommitsRepositoryNode extends SubscribeableViewNode { return this.repo.onDidChange(this.onRepositoryChanged, this); } + protected get requiresResetOnVisible(): boolean { + return this._repoUpdatedAt !== this.repo.updatedAt; + } + + private _repoUpdatedAt: number = this.repo.updatedAt; + @debug({ args: { 0: (e: RepositoryChangeEvent) => @@ -136,6 +142,8 @@ export class CommitsRepositoryNode extends SubscribeableViewNode { }, }) private onRepositoryChanged(e: RepositoryChangeEvent) { + this._repoUpdatedAt = this.repo.updatedAt; + if (e.changed(RepositoryChange.Closed)) { this.dispose(); void this.parent?.triggerChange(true); diff --git a/src/views/contributorsView.ts b/src/views/contributorsView.ts index 33e6073..f869497 100644 --- a/src/views/contributorsView.ts +++ b/src/views/contributorsView.ts @@ -78,6 +78,12 @@ export class ContributorsRepositoryNode extends SubscribeableViewNode @@ -85,6 +91,8 @@ export class ContributorsRepositoryNode extends SubscribeableViewNode { return Disposable.from(...subscriptions); } + protected get requiresResetOnVisible(): boolean { + return true; + } + @debug({ args: false }) private onActiveEditorChanged(editor: TextEditor | undefined) { if (editor == null || this._children === undefined || this._children.length === 1) { diff --git a/src/views/nodes/repositoryNode.ts b/src/views/nodes/repositoryNode.ts index 90f7595..075eb41 100644 --- a/src/views/nodes/repositoryNode.ts +++ b/src/views/nodes/repositoryNode.ts @@ -262,6 +262,12 @@ export class RepositoryNode extends SubscribeableViewNode { return this.view.config.includeWorkingTree; } + protected get requiresResetOnVisible(): boolean { + return this._repoUpdatedAt !== this.repo.updatedAt; + } + + private _repoUpdatedAt: number = this.repo.updatedAt; + @debug({ args: { 0: (e: RepositoryFileSystemChangeEvent) => @@ -272,6 +278,8 @@ export class RepositoryNode extends SubscribeableViewNode { }, }) private async onFileSystemChanged(_e: RepositoryFileSystemChangeEvent) { + this._repoUpdatedAt = this.repo.updatedAt; + this._status = this.repo.getStatus(); if (this._children !== undefined) { @@ -306,6 +314,8 @@ export class RepositoryNode extends SubscribeableViewNode { }, }) private onRepositoryChanged(e: RepositoryChangeEvent) { + this._repoUpdatedAt = this.repo.updatedAt; + if (e.changed(RepositoryChange.Closed)) { this.dispose(); diff --git a/src/views/nodes/viewNode.ts b/src/views/nodes/viewNode.ts index ab82f00..df06434 100644 --- a/src/views/nodes/viewNode.ts +++ b/src/views/nodes/viewNode.ts @@ -221,6 +221,10 @@ export abstract class SubscribeableViewNode extends V } } + protected get requiresResetOnVisible(): boolean { + return false; + } + protected abstract subscribe(): Disposable | undefined | Promise; @debug() @@ -260,7 +264,7 @@ export abstract class SubscribeableViewNode extends V void this.ensureSubscription(); if (e.visible) { - void this.triggerChange(); + void this.triggerChange(this.requiresResetOnVisible); } } diff --git a/src/views/remotesView.ts b/src/views/remotesView.ts index f3570d8..9c0798b 100644 --- a/src/views/remotesView.ts +++ b/src/views/remotesView.ts @@ -91,6 +91,12 @@ export class RemotesRepositoryNode extends SubscribeableViewNode { return this.repo.onDidChange(this.onRepositoryChanged, this); } + protected get requiresResetOnVisible(): boolean { + return this._repoUpdatedAt !== this.repo.updatedAt; + } + + private _repoUpdatedAt: number = this.repo.updatedAt; + @debug({ args: { 0: (e: RepositoryChangeEvent) => @@ -98,6 +104,8 @@ export class RemotesRepositoryNode extends SubscribeableViewNode { }, }) private onRepositoryChanged(e: RepositoryChangeEvent) { + this._repoUpdatedAt = this.repo.updatedAt; + if (e.changed(RepositoryChange.Closed)) { this.dispose(); void this.parent?.triggerChange(true); diff --git a/src/views/stashesView.ts b/src/views/stashesView.ts index ddeb700..1203022 100644 --- a/src/views/stashesView.ts +++ b/src/views/stashesView.ts @@ -79,6 +79,12 @@ export class StashesRepositoryNode extends SubscribeableViewNode { return this.repo.onDidChange(this.onRepositoryChanged, this); } + protected get requiresResetOnVisible(): boolean { + return this._repoUpdatedAt !== this.repo.updatedAt; + } + + private _repoUpdatedAt: number = this.repo.updatedAt; + @debug({ args: { 0: (e: RepositoryChangeEvent) => @@ -86,6 +92,8 @@ export class StashesRepositoryNode extends SubscribeableViewNode { }, }) private onRepositoryChanged(e: RepositoryChangeEvent) { + this._repoUpdatedAt = this.repo.updatedAt; + if (e.changed(RepositoryChange.Closed)) { this.dispose(); void this.parent?.triggerChange(true); diff --git a/src/views/tagsView.ts b/src/views/tagsView.ts index 6ccc608..c1ade93 100644 --- a/src/views/tagsView.ts +++ b/src/views/tagsView.ts @@ -72,6 +72,12 @@ export class TagsRepositoryNode extends SubscribeableViewNode { return this.repo.onDidChange(this.onRepositoryChanged, this); } + protected get requiresResetOnVisible(): boolean { + return this._repoUpdatedAt !== this.repo.updatedAt; + } + + private _repoUpdatedAt: number = this.repo.updatedAt; + @debug({ args: { 0: (e: RepositoryChangeEvent) => @@ -79,6 +85,8 @@ export class TagsRepositoryNode extends SubscribeableViewNode { }, }) private onRepositoryChanged(e: RepositoryChangeEvent) { + this._repoUpdatedAt = this.repo.updatedAt; + if (e.changed(RepositoryChange.Closed)) { this.dispose(); void this.parent?.triggerChange(true);