@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow any inline in the document to be queried by ID

Summary:
Ref T12616. When you "Delete" a comment from the preview, we try to delete the comment on screen too.

It may or may not be present on screen: if you just added it it's usually visible. However, you might also have hidden the file it contains or it could be on an older diff in a file which is no longer present in the current diff.

After updates in T12616, we could only find the comment if you'd previously interacted with it for some reason. Update this code to be able to find all inlines present in the document.

Test Plan:
- Write a draft comment.
- Reload the page.
- DO NOT INTERACT WITH THE COMMENT!
- Delete it from the preview.
- After patch: Comment is deleted from the document, too.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12616

Differential Revision: https://secure.phabricator.com/D17937

+26 -5
+26 -5
webroot/rsrc/js/application/diff/DiffChangeset.js
··· 581 581 }, 582 582 583 583 getInlineByID: function(id) { 584 - // TODO: Currently, this will only find inlines which the user has 585 - // already interacted with! Inlines are built lazily as events arrive. 586 - // This can not yet find inlines which are passively present in the 587 - // document. 584 + // First, look for the inline in the objects we've already built. 585 + var inline = this._findInlineByID(id); 586 + if (inline) { 587 + return inline; 588 + } 588 589 590 + // If we haven't found a matching inline yet, rebuild all the inlines 591 + // present in the document, then look again. 592 + this._rebuildAllInlines(); 593 + return this._findInlineByID(id); 594 + }, 595 + 596 + _findInlineByID: function(id) { 589 597 for (var ii = 0; ii < this._inlines.length; ii++) { 590 598 var inline = this._inlines[ii]; 591 599 if (inline.getID() == id) { ··· 594 602 } 595 603 596 604 return null; 605 + }, 606 + 607 + _rebuildAllInlines: function() { 608 + var rows = JX.DOM.scry(this._node, 'tr'); 609 + for (var ii = 0; ii < rows.length; ii++) { 610 + var row = rows[ii]; 611 + if (this._getRowType(row) != 'comment') { 612 + continue; 613 + } 614 + 615 + // As a side effect, this builds any missing inline objects and adds 616 + // them to this Changeset's list of inlines. 617 + this.getInlineForRow(row); 618 + } 597 619 } 598 - 599 620 600 621 }, 601 622