When replying to a threaded inline, put the new inline in the right place in the thread

Summary:
Fixes T10563. If you have a thread like this:

```
> A
  > B
  > C
```

...and you reply to "B", we should put the new inline below "B".

We currently do when you reload the page, but the initial edit goes at the bottom always (below "C").

Test Plan: {F4963015}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10563

Differential Revision: https://secure.phabricator.com/D17938
This commit is contained in:
epriestley
2017-05-17 11:59:00 -07:00
parent d03a497616
commit 80c329c942
3 changed files with 84 additions and 25 deletions

View File

@@ -581,8 +581,16 @@ JX.install('DiffChangeset', {
},
getInlineByID: function(id) {
return this._queryInline('id', id);
},
getInlineByPHID: function(phid) {
return this._queryInline('phid', phid);
},
_queryInline: function(field, value) {
// First, look for the inline in the objects we've already built.
var inline = this._findInlineByID(id);
var inline = this._findInline(field, value);
if (inline) {
return inline;
}
@@ -590,13 +598,24 @@ JX.install('DiffChangeset', {
// If we haven't found a matching inline yet, rebuild all the inlines
// present in the document, then look again.
this._rebuildAllInlines();
return this._findInlineByID(id);
return this._findInline(field, value);
},
_findInlineByID: function(id) {
_findInline: function(field, value) {
for (var ii = 0; ii < this._inlines.length; ii++) {
var inline = this._inlines[ii];
if (inline.getID() == id) {
var target;
switch (field) {
case 'id':
target = inline.getID();
break;
case 'phid':
target = inline.getPHID();
break;
}
if (target == value) {
return inline;
}
}