1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-25 16:22:43 +01:00

Determine unread count correctly when rendering notification panel

Summary:
Currently, when rendering the panel we count the number of unread notifications in the last 15, but this means we can never render a number larger than 15. If the user has more unread notifications than that, or unread notifications older than the most recent 15, there will be a flash of the higher number and then it will update to the lower number afterward.

Instead, count all unread notifications. This uses the same method used to render both numbers.

Test Plan: Loaded a page, checked the menu, nothing exploded.

Reviewers: btrahan, jungejason, vrana

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T974

Differential Revision: https://secure.phabricator.com/D2811
This commit is contained in:
epriestley 2012-06-20 13:20:41 -07:00
parent 26ca5cbbe3
commit addc2c8764

View file

@ -30,16 +30,9 @@ final class PhabricatorNotificationPanelController
$stories = $query->execute(); $stories = $query->execute();
$num_unconsumed = 0;
if ($stories) { if ($stories) {
$builder = new PhabricatorNotificationBuilder($stories); $builder = new PhabricatorNotificationBuilder($stories);
$notifications_view = $builder->buildView(); $notifications_view = $builder->buildView();
foreach ($stories as $story) {
if (!$story->getHasViewed()) {
$num_unconsumed++;
}
}
$content = $notifications_view->render(); $content = $notifications_view->render();
} else { } else {
$content = $content =
@ -58,9 +51,12 @@ final class PhabricatorNotificationPanelController
'View All Notifications'). 'View All Notifications').
'</div>'; '</div>';
$unread_count = id(new PhabricatorFeedStoryNotification())
->countUnread($user);
$json = array( $json = array(
'content' => $content, 'content' => $content,
'number' => $num_unconsumed, 'number' => $unread_count,
); );
return id(new AphrontAjaxResponse())->setContent($json); return id(new AphrontAjaxResponse())->setContent($json);