Fix local storage with PARENT revision
Previously, if a PARENT revision was getting compared to a patchset, the local storage key would be the same for both, and there were issues if a user was trying to write drafts on the same line on either side. This addresses the issue by storing 'PARENT' as the patch number in the local storage key, so that each key is unique. Bug: Issue 5412 Change-Id: Ia8b2f0abe1d24a3849628fe335c931f07bcaff52
This commit is contained in:
parent
68a23fcfb3
commit
6cd5590a15
polygerrit-ui/app/elements/diff
gr-diff-comment-thread
gr-diff-comment
@ -59,6 +59,7 @@ limitations under the License.
|
||||
draft="[[comment.__draft]]"
|
||||
show-actions="[[_showActions]]"
|
||||
comment-side="[[comment.__commentSide]]"
|
||||
side="[[side]]"
|
||||
project-config="[[projectConfig]]"
|
||||
on-create-fix-comment="_handleCommentFix"
|
||||
on-comment-discard="_handleCommentDiscard"></gr-diff-comment>
|
||||
|
@ -170,7 +170,7 @@
|
||||
_eraseDraftComment: function() {
|
||||
this.$.storage.eraseDraftComment({
|
||||
changeNum: this.changeNum,
|
||||
patchNum: this.patchNum,
|
||||
patchNum: this._getPatchNum(),
|
||||
path: this.comment.path,
|
||||
line: this.comment.line,
|
||||
range: this.comment.range,
|
||||
@ -288,7 +288,7 @@
|
||||
|
||||
var commentLocation = {
|
||||
changeNum: this.changeNum,
|
||||
patchNum: this.patchNum,
|
||||
patchNum: this._getPatchNum(),
|
||||
path: this.comment.path,
|
||||
line: this.comment.line,
|
||||
range: this.comment.range,
|
||||
@ -410,6 +410,10 @@
|
||||
draft);
|
||||
},
|
||||
|
||||
_getPatchNum: function() {
|
||||
return this.side === 'PARENT' ? 'PARENT' : this.patchNum;
|
||||
},
|
||||
|
||||
_loadLocalDraft: function(changeNum, patchNum, comment) {
|
||||
// Only apply local drafts to comments that haven't been saved
|
||||
// remotely, and haven't been given a default message already.
|
||||
@ -423,7 +427,7 @@
|
||||
|
||||
var draft = this.$.storage.getDraftComment({
|
||||
changeNum: changeNum,
|
||||
patchNum: patchNum,
|
||||
patchNum: this._getPatchNum(),
|
||||
path: comment.path,
|
||||
line: comment.line,
|
||||
range: comment.range,
|
||||
|
@ -152,6 +152,14 @@ limitations under the License.
|
||||
});
|
||||
});
|
||||
|
||||
test('_getPatchNum', function() {
|
||||
element.side = 'PARENT';
|
||||
element.patchNum = 1;
|
||||
assert.equal(element._getPatchNum(), 'PARENT');
|
||||
element.side = 'REVISION';
|
||||
assert.equal(element._getPatchNum(), 1);
|
||||
});
|
||||
|
||||
test('comment expand and collapse', function() {
|
||||
element.collapsed = true;
|
||||
assert.isFalse(isVisible(element.$$('gr-formatted-text')),
|
||||
|
Loading…
x
Reference in New Issue
Block a user