1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Fix some quirkiness with Answer comments in Ponder

Summary: There is still some general buginess with answer comments, trying to work them out. This replaces timeline rendering into one offs (less performant) but resolves many bugs. Or if there is a more performant way, let me know? Also when leaving an answer comment, you currently get redirected back to the page, but both the comment form is still populated and you dont see your answer without a reload. I feel like I'm missing some magical parameter to pass, so just redirecting back to the question itself.

Test Plan: Leave lots of answer comments.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D13946
This commit is contained in:
Chad Little 2015-08-20 11:23:30 -07:00
parent 233b2d5a6e
commit 5317f77f30
5 changed files with 22 additions and 38 deletions

View file

@ -93,7 +93,7 @@ return array(
'rsrc/css/application/policy/policy-edit.css' => '815c66f7',
'rsrc/css/application/policy/policy-transaction-detail.css' => '82100a43',
'rsrc/css/application/policy/policy.css' => '957ea14c',
'rsrc/css/application/ponder/ponder-view.css' => '870153f4',
'rsrc/css/application/ponder/ponder-view.css' => 'bef48f86',
'rsrc/css/application/projects/project-icon.css' => '4e3eaa5a',
'rsrc/css/application/releeph/releeph-core.css' => '9b3c5733',
'rsrc/css/application/releeph/releeph-preview-branch.css' => 'b7a6f4a5',
@ -811,7 +811,7 @@ return array(
'policy-css' => '957ea14c',
'policy-edit-css' => '815c66f7',
'policy-transaction-detail-css' => '82100a43',
'ponder-view-css' => '870153f4',
'ponder-view-css' => 'bef48f86',
'project-icon-css' => '4e3eaa5a',
'raphael-core' => '51ee6b43',
'raphael-g' => '40dde778',

View file

@ -19,11 +19,12 @@ final class PonderAnswerCommentController extends PonderController {
}
$is_preview = $request->isPreviewRequest();
// $draft = PhabricatorDraft::buildFromRequest($request);
$qid = $answer->getQuestion()->getID();
$aid = $answer->getID();
$view_uri = "/Q{$qid}#A{$aid}";
// TODO, this behaves badly when redirecting to the answer
$view_uri = "/Q{$qid}";
$xactions = array();
$xactions[] = id(new PonderAnswerTransaction())
@ -46,9 +47,6 @@ final class PonderAnswerCommentController extends PonderController {
->setException($ex);
}
// if ($draft) {
// $draft->replaceOrDelete();
// }
if ($request->isAjax() && $is_preview) {
return id(new PhabricatorApplicationTransactionResponse())

View file

@ -205,40 +205,28 @@ final class PonderQuestionViewController extends PonderController {
private function buildAnswers(array $answers) {
$viewer = $this->getViewer();
$xactions = id(new PonderAnswerTransactionQuery())
->setViewer($viewer)
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT))
->withObjectPHIDs(mpull($answers, 'getPHID'))
->execute();
$engine = id(new PhabricatorMarkupEngine())
->setViewer($viewer);
foreach ($xactions as $xaction) {
if ($xaction->getComment()) {
$engine->addObject(
$xaction->getComment(),
PhabricatorApplicationTransactionComment::MARKUP_FIELD_COMMENT);
}
}
$engine->process();
$xaction_groups = mgroup($xactions, 'getObjectPHID');
$author_phids = mpull($answers, 'getAuthorPHID');
$handles = $this->loadViewerHandles($author_phids);
$answers_sort = array_reverse(msort($answers, 'getVoteCount'));
$view = array();
foreach ($answers_sort as $answer) {
$xactions = idx($xaction_groups, $answer->getPHID(), array());
$id = $answer->getID();
$handle = $handles[$answer->getAuthorPHID()];
$timeline = $this->buildTransactionTimeline(
$answer,
id(new PonderAnswerTransactionQuery())
->withTransactionTypes(array(PhabricatorTransactions::TYPE_COMMENT)));
$xactions = $timeline->getTransactions();
$view[] = id(new PonderAnswerView())
->setUser($viewer)
->setAnswer($answer)
->setTransactions($xactions)
->setHandle($handle)
->setMarkupEngine($engine);
->setTimeline($timeline)
->setHandle($handle);
}

View file

@ -4,7 +4,7 @@ final class PonderAnswerView extends AphrontTagView {
private $answer;
private $transactions;
private $engine;
private $timeline;
private $handle;
public function setAnswer($answer) {
@ -17,8 +17,8 @@ final class PonderAnswerView extends AphrontTagView {
return $this;
}
public function setMarkupEngine(PhabricatorMarkupEngine $engine) {
$this->engine = $engine;
public function setTimeline($timeline) {
$this->timeline = $timeline;
return $this;
}
@ -124,12 +124,6 @@ final class PonderAnswerView extends AphrontTagView {
->appendChild($content)
->appendChild($footer);
$transaction_view = id(new PhabricatorApplicationTransactionView())
->setUser($viewer)
->setObjectPHID($answer->getPHID())
->setTransactions($this->transactions)
->setMarkupEngine($this->engine);
$comment_view = id(new PhabricatorApplicationTransactionCommentView())
->setUser($viewer)
->setObjectPHID($answer->getPHID())
@ -145,7 +139,7 @@ final class PonderAnswerView extends AphrontTagView {
'style' => 'display: none;',
),
array(
$transaction_view,
$this->timeline,
$comment_view,
));

View file

@ -26,6 +26,10 @@
margin-top: 16px;
}
.device-desktop .ponder-answer-view .phui-timeline-view {
margin-left: 32px;
}
.ponder-answer-view .phui-header-subheader {
display: inline;
margin-left: 12px;