'Load more' check should be based on retrieved data, not what could render

Since EchoEventPresentationModel::canRender can reject notifications,
its result should no longer be used for infinite scroll.

Current code checks if the amount of to-be-rendered data exceeds what
we need to display, but if we reject some notifications that may no
longer be the case, even though there is more data still.

Change-Id: I3e5f8c2d1fc0c63db7b277324c96af043689ddce
This commit is contained in:
Matthias Mullie 2015-11-18 11:06:20 +01:00
parent 643cf2a3a3
commit a35bf21084

View file

@ -50,6 +50,14 @@ class SpecialNotifications extends SpecialPage {
$continue,
$attributeManager->getUserEnabledEvents( $user, 'web' )
);
// If there are no notifications, display a message saying so
if ( !$notifications ) {
$out->addWikiMsg( 'echo-none' );
return;
}
foreach ( $notifications as $notification ) {
$output = EchoDataOutputFormatter::formatOutput( $notification, 'html', $user, $this->getLanguage() );
if ( $output ) {
@ -57,15 +65,8 @@ class SpecialNotifications extends SpecialPage {
}
}
// If there are no notifications, display a message saying so
if ( !$notif ) {
$out->addWikiMsg( 'echo-none' );
return;
}
// Check if there is more data to load for next request
if ( count( $notif ) > self::DISPLAY_NUM ) {
if ( count( $notifications ) > self::DISPLAY_NUM ) {
$lastItem = array_pop( $notif );
$nextContinue = $lastItem['timestamp']['utcunix'] . '|' . $lastItem['id'];
} else {