mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-22 12:41:19 +01:00
Order inline comments in Diffusion consistently with Differential
Summary: Fixes T8739. Currently, Diffusion inline comments in the timeline are sorted arbitrarily, mostly by creation order. Instead, sort them by line number, like Differential. Test Plan: Made comments in "C", "B", "A" order, saw them in line order after submit: {F2343032} Reviewers: chad Reviewed By: chad Maniphest Tasks: T8739 Differential Revision: https://secure.phabricator.com/D17184
This commit is contained in:
parent
b5722a9963
commit
b471f6c07a
1 changed files with 46 additions and 36 deletions
|
@ -81,48 +81,58 @@ final class PhabricatorAuditTransactionView
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($inlines) {
|
$structs = array();
|
||||||
|
foreach ($inlines as $key => $inline) {
|
||||||
// TODO: This should do something similar to sortAndGroupInlines() to get
|
$comment = $inline->getComment();
|
||||||
// a stable ordering.
|
if (!$comment) {
|
||||||
|
// TODO: Migrate these away? They probably do not exist on normal
|
||||||
$inlines_by_path = array();
|
// non-development installs.
|
||||||
foreach ($inlines as $key => $inline) {
|
unset($inlines[$key]);
|
||||||
$comment = $inline->getComment();
|
continue;
|
||||||
if (!$comment) {
|
|
||||||
// TODO: Migrate these away? They probably do not exist on normal
|
|
||||||
// non-development installs.
|
|
||||||
unset($inlines[$key]);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$path_id = $comment->getPathID();
|
|
||||||
$inlines_by_path[$path_id][] = $inline;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$inline_view = new PhabricatorInlineSummaryView();
|
$path_id = $comment->getPathID();
|
||||||
foreach ($inlines_by_path as $path_id => $group) {
|
$path = idx($this->pathMap, $path_id);
|
||||||
$path = idx($this->pathMap, $path_id);
|
if ($path === null) {
|
||||||
if ($path === null) {
|
continue;
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$items = array();
|
|
||||||
foreach ($group as $inline) {
|
|
||||||
$comment = $inline->getComment();
|
|
||||||
$item = array(
|
|
||||||
'id' => $comment->getID(),
|
|
||||||
'line' => $comment->getLineNumber(),
|
|
||||||
'length' => $comment->getLineLength(),
|
|
||||||
'content' => parent::renderTransactionContent($inline),
|
|
||||||
);
|
|
||||||
$items[] = $item;
|
|
||||||
}
|
|
||||||
$inline_view->addCommentGroup($path, $items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$out[] = $inline_view;
|
$structs[] = array(
|
||||||
|
'inline' => $inline,
|
||||||
|
'path' => $path,
|
||||||
|
'sort' => (string)id(new PhutilSortVector())
|
||||||
|
->addString($path)
|
||||||
|
->addInt($comment->getLineNumber())
|
||||||
|
->addInt($comment->getLineLength())
|
||||||
|
->addInt($inline->getID()),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$structs) {
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
$structs = isort($structs, 'sort');
|
||||||
|
$structs = igroup($structs, 'path');
|
||||||
|
|
||||||
|
$inline_view = new PhabricatorInlineSummaryView();
|
||||||
|
foreach ($structs as $path => $group) {
|
||||||
|
$inlines = ipull($group, 'inline');
|
||||||
|
$items = array();
|
||||||
|
foreach ($inlines as $inline) {
|
||||||
|
$comment = $inline->getComment();
|
||||||
|
$items[] = array(
|
||||||
|
'id' => $comment->getID(),
|
||||||
|
'line' => $comment->getLineNumber(),
|
||||||
|
'length' => $comment->getLineLength(),
|
||||||
|
'content' => parent::renderTransactionContent($inline),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$inline_view->addCommentGroup($path, $items);
|
||||||
|
}
|
||||||
|
|
||||||
|
$out[] = $inline_view;
|
||||||
|
|
||||||
return $out;
|
return $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue