Fix range issue with comment replies
- Adds range when parent exists when comment POSTed - Finds range via filtering comments for backfill Bug: Issue 5459 Change-Id: Ied19cc4b33749ba81fad6d1a5030abab419b1e6f
This commit is contained in:
parent
debaf78b56
commit
8c19a02e67
polygerrit-ui/app/elements
diff/gr-diff-comment-thread
shared/gr-rest-api-interface
@ -83,7 +83,7 @@
|
||||
lastComment.id || lastComment.__draftID);
|
||||
commentEl.editing = true;
|
||||
} else {
|
||||
this.addDraft(opt_lineNum);
|
||||
this.addDraft(opt_lineNum, lastComment.range);
|
||||
}
|
||||
},
|
||||
|
||||
@ -159,7 +159,8 @@
|
||||
this._orderedComments[this._orderedComments.length - 1].id,
|
||||
parent.line,
|
||||
content,
|
||||
opt_unresolved);
|
||||
opt_unresolved,
|
||||
parent.range);
|
||||
|
||||
// If there is currently a comment in an editing state, add an attribute
|
||||
// so that the gr-diff-comment knows not to populate the draft text.
|
||||
@ -223,9 +224,11 @@
|
||||
return null;
|
||||
},
|
||||
|
||||
_newReply: function(inReplyTo, opt_lineNum, opt_message, opt_unresolved) {
|
||||
_newReply: function(inReplyTo, opt_lineNum, opt_message, opt_unresolved,
|
||||
opt_range) {
|
||||
var d = this._newDraft(opt_lineNum);
|
||||
d.in_reply_to = inReplyTo;
|
||||
d.range = opt_range;
|
||||
if (opt_message != null) {
|
||||
d.message = opt_message;
|
||||
}
|
||||
|
@ -728,6 +728,26 @@
|
||||
this._getDiffCommentsFetchURL(changeNum, endpoint, opt_patchNum);
|
||||
promises.push(this.fetchJSON(url).then(function(response) {
|
||||
comments = response[opt_path] || [];
|
||||
|
||||
// TODO(kaspern): Implement this on in the backend so this can be
|
||||
// removed.
|
||||
|
||||
// Sort comments by date so that parent ranges can be propagated in a
|
||||
// single pass.
|
||||
comments = comments.sort(function(a, b) {
|
||||
return a.updated > b.updated;
|
||||
});
|
||||
comments.forEach(function(comment){
|
||||
if (comment.in_reply_to && !comment.range) {
|
||||
for (var i = 0; i < comments.length; i++) {
|
||||
if (comments[i].id === comment.in_reply_to) {
|
||||
comment.range = comments[i].range;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if (opt_basePatchNum == PARENT_PATCH_NUM) {
|
||||
baseComments = comments.filter(onlyParent);
|
||||
baseComments.forEach(setPath);
|
||||
|
Loading…
x
Reference in New Issue
Block a user