Browse Source

Fixes view refresh on repo/fs changes while hidden

main
Eric Amodio 4 years ago
parent
commit
f56524f857
12 changed files with 88 additions and 5 deletions
  1. +9
    -0
      src/git/models/repository.ts
  2. +8
    -0
      src/views/branchesView.ts
  3. +8
    -0
      src/views/commitsView.ts
  4. +8
    -0
      src/views/contributorsView.ts
  5. +6
    -2
      src/views/nodes/fileHistoryNode.ts
  6. +6
    -2
      src/views/nodes/lineHistoryNode.ts
  7. +4
    -0
      src/views/nodes/repositoriesNode.ts
  8. +10
    -0
      src/views/nodes/repositoryNode.ts
  9. +5
    -1
      src/views/nodes/viewNode.ts
  10. +8
    -0
      src/views/remotesView.ts
  11. +8
    -0
      src/views/stashesView.ts
  12. +8
    -0
      src/views/tagsView.ts

+ 9
- 0
src/git/models/repository.ts View File

@ -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);
}

+ 8
- 0
src/views/branchesView.ts View File

@ -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);

+ 8
- 0
src/views/commitsView.ts View File

@ -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);

+ 8
- 0
src/views/contributorsView.ts View File

@ -78,6 +78,12 @@ export class ContributorsRepositoryNode extends SubscribeableViewNode
);
}
protected get requiresResetOnVisible(): boolean {
return this._repoUpdatedAt !== this.repo.updatedAt;
}
private _repoUpdatedAt: number = this.repo.updatedAt;
@debug({
args: {
0: (e: RepositoryChangeEvent) =>
@ -85,6 +91,8 @@ export class ContributorsRepositoryNode extends SubscribeableViewNode
},
})
private onRepositoryChanged(e: RepositoryChangeEvent) {
this._repoUpdatedAt = this.repo.updatedAt;
if (e.changed(RepositoryChange.Closed)) {
this.dispose();
void this.parent?.triggerChange(true);

+ 6
- 2
src/views/nodes/fileHistoryNode.ts View File

@ -140,12 +140,16 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
return subscription;
}
protected get requiresResetOnVisible(): boolean {
return true;
}
private onRepoChanged(e: RepositoryChangeEvent) {
if (!e.changed(RepositoryChange.Heads)) return;
Logger.debug(`FileHistoryNode.onRepoChanged(${e.changes.join()}); triggering node refresh`);
void this.triggerChange();
void this.triggerChange(true);
}
private onRepoFileSystemChanged(e: RepositoryFileSystemChangeEvent) {
@ -153,7 +157,7 @@ export class FileHistoryNode extends SubscribeableViewNode implements PageableVi
Logger.debug(`FileHistoryNode.onRepoFileSystemChanged(${this.uri.toString(true)}); triggering node refresh`);
void this.triggerChange();
void this.triggerChange(true);
}
@gate()

+ 6
- 2
src/views/nodes/lineHistoryNode.ts View File

@ -270,12 +270,16 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
return subscription;
}
protected get requiresResetOnVisible(): boolean {
return true;
}
private onRepoChanged(e: RepositoryChangeEvent) {
if (!e.changed(RepositoryChange.Heads)) return;
Logger.debug(`LineHistoryNode.onRepoChanged(${e.changes.join()}); triggering node refresh`);
void this.triggerChange();
void this.triggerChange(true);
}
private onRepoFileSystemChanged(e: RepositoryFileSystemChangeEvent) {
@ -283,7 +287,7 @@ export class LineHistoryNode extends SubscribeableViewNode implements PageableVi
Logger.debug(`LineHistoryNode.onRepoFileSystemChanged(${this.uri.toString(true)}); triggering node refresh`);
void this.triggerChange();
void this.triggerChange(true);
}
@gate()

+ 4
- 0
src/views/nodes/repositoriesNode.ts View File

@ -109,6 +109,10 @@ export class RepositoriesNode 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) {

+ 10
- 0
src/views/nodes/repositoryNode.ts View File

@ -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();

+ 5
- 1
src/views/nodes/viewNode.ts View File

@ -221,6 +221,10 @@ export abstract class SubscribeableViewNode extends V
}
}
protected get requiresResetOnVisible(): boolean {
return false;
}
protected abstract subscribe(): Disposable | undefined | Promise<Disposable | undefined>;
@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);
}
}

+ 8
- 0
src/views/remotesView.ts View File

@ -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);

+ 8
- 0
src/views/stashesView.ts View File

@ -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);

+ 8
- 0
src/views/tagsView.ts View File

@ -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);

Loading…
Cancel
Save