Merge "Coalesce request for drafts with login check"
This commit is contained in:
@@ -51,11 +51,7 @@
|
||||
.then(comments => { this._comments = comments; }));
|
||||
promises.push(this.$.restAPI.getDiffRobotComments(changeNum)
|
||||
.then(robotComments => { this._robotComments = robotComments; }));
|
||||
promises.push(this.$.restAPI.getLoggedIn()
|
||||
.then(loggedIn => {
|
||||
if (!loggedIn) { return Promise.resolve({}); }
|
||||
return this.$.restAPI.getDiffDrafts(changeNum);
|
||||
})
|
||||
promises.push(this.$.restAPI.getDiffDrafts(changeNum)
|
||||
.then(drafts => { this._drafts = drafts; }));
|
||||
|
||||
return Promise.all(promises);
|
||||
|
||||
@@ -57,14 +57,16 @@ limitations under the License.
|
||||
}));
|
||||
sandbox.stub(element.$.restAPI, 'getDiffRobotComments')
|
||||
.returns(Promise.resolve({'foo.c': [{id: '321', message: 'done'}]}));
|
||||
sandbox.stub(element.$.restAPI, 'getDiffDrafts');
|
||||
sandbox.stub(element.$.restAPI, 'getDiffDrafts')
|
||||
.returns(Promise.resolve({}));
|
||||
|
||||
return element.loadAll(changeNum).then(() => {
|
||||
assert.isTrue(element.$.restAPI.getDiffComments.calledWithExactly(
|
||||
changeNum));
|
||||
assert.isTrue(element.$.restAPI.getDiffRobotComments.calledWithExactly(
|
||||
changeNum));
|
||||
assert.isFalse(element.$.restAPI.getDiffDrafts.called);
|
||||
assert.isTrue(element.$.restAPI.getDiffDrafts.calledWithExactly(
|
||||
changeNum));
|
||||
assert.isOk(element._comments);
|
||||
assert.isOk(element._robotComments);
|
||||
assert.deepEqual(element._drafts, {});
|
||||
|
||||
@@ -730,10 +730,7 @@
|
||||
},
|
||||
|
||||
_getDiffDrafts() {
|
||||
return this._getLoggedIn().then(loggedIn => {
|
||||
if (!loggedIn) { return Promise.resolve({}); }
|
||||
return this.$.restAPI.getDiffDrafts(this._changeNum);
|
||||
});
|
||||
return this.$.restAPI.getDiffDrafts(this._changeNum);
|
||||
},
|
||||
|
||||
_computeCommentSkips(commentMap, fileList, path) {
|
||||
|
||||
@@ -940,9 +940,23 @@
|
||||
patchNum, opt_path);
|
||||
},
|
||||
|
||||
/**
|
||||
* If the user is logged in, fetch the user's draft diff comments. If there
|
||||
* is no logged in user, the request is not made and the promise yields an
|
||||
* empty object.
|
||||
*
|
||||
* @param {number|string} changeNum
|
||||
* @param {number|string} opt_basePatchNum
|
||||
* @param {number|string} opt_patchNum
|
||||
* @param {string} opt_path
|
||||
* @return {Promise<Object>}
|
||||
*/
|
||||
getDiffDrafts(changeNum, opt_basePatchNum, opt_patchNum, opt_path) {
|
||||
return this._getDiffComments(changeNum, '/drafts', opt_basePatchNum,
|
||||
opt_patchNum, opt_path);
|
||||
return this.getLoggedIn().then(loggedIn => {
|
||||
if (!loggedIn) { return Promise.resolve({}); }
|
||||
return this._getDiffComments(changeNum, '/drafts', opt_basePatchNum,
|
||||
opt_patchNum, opt_path);
|
||||
});
|
||||
},
|
||||
|
||||
_setRange(comments, comment) {
|
||||
|
||||
Reference in New Issue
Block a user