Ensure reply dialog comments are properly sorted
When making inline comments, they were appended, which means they
would appear in the order that they were added. Ensure proper
sorting based on the line number (or -1 if it’s a file comment).
Change-Id: Ic1ba951184a468d78b09581831e2b4623fbfb7e2
diff --git a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
index e6d1a64..ac52c91 100644
--- a/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
+++ b/polygerrit-ui/app/elements/change/gr-change-view/gr-change-view.js
@@ -217,6 +217,11 @@
}
}
diffDrafts[draft.path].push(draft);
+ diffDrafts[draft.path].sort(function(c1, c2) {
+ // No line number means that it’s a file comment. Sort it above the
+ // others.
+ return (c1.line || -1) - (c2.line || -1);
+ });
this._diffDrafts = diffDrafts;
},