From 1f8b237a0f4e9a53f1eb224ebad920876f527cdf Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 2 Apr 2013 10:34:24 -0700 Subject: [PATCH] Stop Conpherence from reloading all messages on reply Summary: Currently, when you reply to a Conpherence thread, we load //all// the messages, not just the most recent ones. I don't //think// I broke this, it's just hard to tell that's what's happening unless the thread is very short or you scroll up. The issue is that we're loading //threads// after some ID, but actually need to load //messages// (transactions) after that ID. Also, the way "before" and "after" work is sort of weird so this actually needs to be "before" (we should probably invert the meanings). Ref T2421. Test Plan: Replied to a very short thread; saw no duplicate messages. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T2421 Differential Revision: https://secure.phabricator.com/D5537 --- .../controller/ConpherenceUpdateController.php | 2 +- .../conpherence/query/ConpherenceThreadQuery.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/applications/conpherence/controller/ConpherenceUpdateController.php b/src/applications/conpherence/controller/ConpherenceUpdateController.php index 19aafe7aa4..4782724f5c 100644 --- a/src/applications/conpherence/controller/ConpherenceUpdateController.php +++ b/src/applications/conpherence/controller/ConpherenceUpdateController.php @@ -324,7 +324,7 @@ final class ConpherenceUpdateController $user = $this->getRequest()->getUser(); $conpherence = id(new ConpherenceThreadQuery()) ->setViewer($user) - ->setAfterID($latest_transaction_id) + ->setBeforeMessageID($latest_transaction_id) ->needHeaderPics(true) ->needWidgetData(true) ->needAllTransactions(true) diff --git a/src/applications/conpherence/query/ConpherenceThreadQuery.php b/src/applications/conpherence/query/ConpherenceThreadQuery.php index bf2904ac8e..4ad982dbaa 100644 --- a/src/applications/conpherence/query/ConpherenceThreadQuery.php +++ b/src/applications/conpherence/query/ConpherenceThreadQuery.php @@ -12,6 +12,7 @@ final class ConpherenceThreadQuery private $needHeaderPics; private $needOrigPics; private $needAllTransactions; + private $beforeMessageID; public function needOrigPics($need_orig_pics) { $this->needOrigPics = $need_orig_pics; @@ -43,6 +44,12 @@ final class ConpherenceThreadQuery return $this; } + // TODO: This is pretty hacky! + public function setBeforeMessageID($id) { + $this->beforeMessageID = $id; + return $this; + } + protected function loadPage() { $table = new ConpherenceThread(); $conn_r = $table->establishConnection('r'); @@ -124,6 +131,7 @@ final class ConpherenceThreadQuery ->setViewer($this->getViewer()) ->withObjectPHIDs(array_keys($conpherences)) ->needHandles(true) + ->setBeforeID($this->beforeMessageID) ->execute(); $transactions = mgroup($transactions, 'getObjectPHID'); foreach ($conpherences as $phid => $conpherence) {