From bc04c0b909ce6d75e28ec690427b59a103a1531a Mon Sep 17 00:00:00 2001 From: Richard Kotze Date: Mon, 4 Jan 2021 19:29:59 +0000 Subject: [PATCH] Ensure the counts update when adding a new co-author Adding a new author via the .git-co-author file would not update the numbers. Decided to have one event for when the list changes and means there does not beed to be a special _change method to subscribe to. #3 --- .../co-authors-provider.js | 21 ------------------- .../count-decorator-provider.js | 2 +- .../count-decorator-provider.spec.js | 2 +- src/setup-git-mob.js | 2 +- 4 files changed, 3 insertions(+), 24 deletions(-) diff --git a/src/co-author-tree-provider/co-authors-provider.js b/src/co-author-tree-provider/co-authors-provider.js index c60eabd..d9129e0 100644 --- a/src/co-author-tree-provider/co-authors-provider.js +++ b/src/co-author-tree-provider/co-authors-provider.js @@ -14,8 +14,6 @@ class CoAuthorProvider { this._notLoaded = true; this._selected = []; this.multiSelected = []; - this._onCoAuthorChange = new vscode.EventEmitter(); - this.onCoAuthorChange = this._onCoAuthorChange.event; this._onDidChangeTreeData = new vscode.EventEmitter(); this.onDidChangeTreeData = this._onDidChangeTreeData.event; this.mobAuthors = new MobAuthors(); @@ -55,13 +53,6 @@ class CoAuthorProvider { this._notLoaded = false; } - if ( - element.email === this.mobAuthors.lastCoAuthor.email && - this._changed() - ) { - this._onCoAuthorChange.fire(); - } - return element; } @@ -77,18 +68,6 @@ class CoAuthorProvider { this.reloadData(); } - _changed() { - const currentSelected = this.mobAuthors.listAll.filter( - (coAuthors) => coAuthors.selected - ); - - const isDiff = this._selected.length !== currentSelected.length; - - this._selected = currentSelected; - - return isDiff; - } - reloadData() { this.multiSelected = []; this._onDidChangeTreeData.fire(); diff --git a/src/co-author-tree-provider/count-decorator-provider.js b/src/co-author-tree-provider/count-decorator-provider.js index bc74bf7..56fd793 100644 --- a/src/co-author-tree-provider/count-decorator-provider.js +++ b/src/co-author-tree-provider/count-decorator-provider.js @@ -12,7 +12,7 @@ class CountDecorationProvider { handleChange() { const changeDecoration = this._onDidChangeDecorations; - this.coAuthorProvider.onCoAuthorChange(function () { + this.coAuthorProvider.onDidChangeTreeData(function () { changeDecoration.fire(); }); } diff --git a/src/co-author-tree-provider/count-decorator-provider.spec.js b/src/co-author-tree-provider/count-decorator-provider.spec.js index b52abb8..7e50cd9 100644 --- a/src/co-author-tree-provider/count-decorator-provider.spec.js +++ b/src/co-author-tree-provider/count-decorator-provider.spec.js @@ -7,7 +7,7 @@ describe("Count co-authors", function () { listCurrent: new Array(2), repoAuthorList: jest.fn().mockResolvedValue(new Array(30)), }, - onCoAuthorChange: jest.fn(), + onDidChangeTreeData: jest.fn(), }; it("should be two selected", async function () { diff --git a/src/setup-git-mob.js b/src/setup-git-mob.js index ab3aeb3..429ac9d 100644 --- a/src/setup-git-mob.js +++ b/src/setup-git-mob.js @@ -42,7 +42,7 @@ function bootGitMob(context, gitExt) { }); }; - coAuthorProvider.onCoAuthorChange(function () { + coAuthorProvider.onDidChangeTreeData(function () { try { gitExt.updateSelectedInput( replaceCoAuthors(coAuthorProvider.mobAuthors.listCurrent)