From b09168e689ff1ce810168c5848ea2259d38d0348 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 4 Mar 2015 10:36:01 -0800 Subject: [PATCH] Show "Show Older" for transactions the user has not interacted with Summary: Fixes T7454. We weren't triggering "Show Older" unless there were hidden events because of a previous interaction. Test Plan: - Set page size to 3. - Viewed a task with ~10 transactions. - Before patch: - Only 3 most recent transactions visible, no way to see older ones. - Saw "show older" appear, paged backward through transaction histroy. - Also, interacted with task and then viewed it, made sure "show older" still works. Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T7454 Differential Revision: https://secure.phabricator.com/D11963 --- src/view/control/AphrontCursorPagerView.php | 4 ++++ src/view/phui/PHUITimelineView.php | 21 +++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/view/control/AphrontCursorPagerView.php b/src/view/control/AphrontCursorPagerView.php index fe6089c4b0..a683eb3d6d 100644 --- a/src/view/control/AphrontCursorPagerView.php +++ b/src/view/control/AphrontCursorPagerView.php @@ -79,6 +79,10 @@ final class AphrontCursorPagerView extends AphrontView { return $results; } + final public function getHasMoreResults() { + return $this->moreResults; + } + public function willShowPagingControls() { return $this->prevPageID || $this->nextPageID || diff --git a/src/view/phui/PHUITimelineView.php b/src/view/phui/PHUITimelineView.php index a31d9cf8a3..fe8cdc5971 100644 --- a/src/view/phui/PHUITimelineView.php +++ b/src/view/phui/PHUITimelineView.php @@ -94,6 +94,9 @@ final class PHUITimelineView extends AphrontView { $hide = array(); $show = array(); + // Bucket timeline events into events we'll hide by default (because they + // predate your most recent interaction with the object) and events we'll + // show by default. foreach ($this->events as $event) { if ($event->getHideByDefault()) { $hide[] = $event; @@ -102,8 +105,18 @@ final class PHUITimelineView extends AphrontView { } } + // If you've never interacted with the object, all the events will be shown + // by default. We may still need to paginate if there are a large number + // of events. + $more = (bool)$hide; + if ($this->getPager()) { + if ($this->getPager()->getHasMoreResults()) { + $more = true; + } + } + $events = array(); - if ($hide && $this->getPager()) { + if ($more && $this->getPager()) { $uri = $this->getPager()->getNextPageURI(); $uri->setQueryParam('quoteTargetID', $this->getQuoteTargetID()); $uri->setQueryParam('quoteRef', $this->getQuoteRef()); @@ -125,10 +138,10 @@ final class PHUITimelineView extends AphrontView { ), pht('Show older changes.')), )); - } - if ($hide && $show) { - $events[] = $spacer; + if ($show) { + $events[] = $spacer; + } } if ($show) {