mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 22:10:55 +01:00
Simplify timeline rendering on Differential revisions
Summary: Ref T7447. Remove the `loadInlineComments()` by-ref side-effect mess and make this load more direct. Test Plan: - Viewed a revision. - Clicked "Show Older". Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7447 Differential Revision: https://secure.phabricator.com/D12496
This commit is contained in:
parent
a4a65bd5f1
commit
d8bd3efa2c
1 changed files with 17 additions and 48 deletions
|
@ -280,46 +280,6 @@ final class DifferentialRevision extends DifferentialDAO
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadInlineComments(
|
|
||||||
array &$changesets,
|
|
||||||
PhabricatorUser $viewer) {
|
|
||||||
assert_instances_of($changesets, 'DifferentialChangeset');
|
|
||||||
|
|
||||||
$inline_comments = array();
|
|
||||||
|
|
||||||
$inline_comments = id(new DifferentialInlineCommentQuery())
|
|
||||||
->setViewer($viewer)
|
|
||||||
->withDrafts(false)
|
|
||||||
->withRevisionPHIDs(array($this->getPHID()))
|
|
||||||
->execute();
|
|
||||||
|
|
||||||
$load_changesets = array();
|
|
||||||
foreach ($inline_comments as $inline) {
|
|
||||||
$changeset_id = $inline->getChangesetID();
|
|
||||||
if (isset($changesets[$changeset_id])) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$load_changesets[$changeset_id] = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$more_changesets = array();
|
|
||||||
if ($load_changesets) {
|
|
||||||
$changeset_ids = array_keys($load_changesets);
|
|
||||||
$more_changesets += id(new DifferentialChangeset())
|
|
||||||
->loadAllWhere(
|
|
||||||
'id IN (%Ld)',
|
|
||||||
$changeset_ids);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($more_changesets) {
|
|
||||||
$changesets += $more_changesets;
|
|
||||||
$changesets = msort($changesets, 'getSortKey');
|
|
||||||
}
|
|
||||||
|
|
||||||
return $inline_comments;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public function getCapabilities() {
|
public function getCapabilities() {
|
||||||
return array(
|
return array(
|
||||||
PhabricatorPolicyCapability::CAN_VIEW,
|
PhabricatorPolicyCapability::CAN_VIEW,
|
||||||
|
@ -531,14 +491,23 @@ final class DifferentialRevision extends DifferentialDAO
|
||||||
$left_diff = $diffs[$left];
|
$left_diff = $diffs[$left];
|
||||||
$right_diff = $diffs[$right];
|
$right_diff = $diffs[$right];
|
||||||
|
|
||||||
$changesets = id(new DifferentialChangesetQuery())
|
$type_inline = DifferentialTransaction::TYPE_INLINE;
|
||||||
->setViewer($request->getUser())
|
$changeset_ids = array();
|
||||||
->withDiffs(array($right_diff))
|
foreach ($timeline->getTransactions() as $xaction) {
|
||||||
->execute();
|
if ($xaction->getTransactionType() == $type_inline) {
|
||||||
// NOTE: this mutates $changesets to include changesets for all inline
|
$changeset_ids[] = $xaction->getComment()->getChangesetID();
|
||||||
// comments...!
|
}
|
||||||
$inlines = $this->loadInlineComments($changesets, $request->getViewer());
|
}
|
||||||
$changesets = mpull($changesets, null, 'getID');
|
|
||||||
|
if ($changeset_ids) {
|
||||||
|
$changesets = id(new DifferentialChangesetQuery())
|
||||||
|
->setViewer($request->getUser())
|
||||||
|
->withIDs($changeset_ids)
|
||||||
|
->execute();
|
||||||
|
$changesets = mpull($changesets, null, 'getID');
|
||||||
|
} else {
|
||||||
|
$changesets = array();
|
||||||
|
}
|
||||||
|
|
||||||
return $timeline
|
return $timeline
|
||||||
->setChangesets($changesets)
|
->setChangesets($changesets)
|
||||||
|
|
Loading…
Reference in a new issue