From addc2c876471618df461d7fe9682ed2119e3ec07 Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 20 Jun 2012 13:20:41 -0700 Subject: [PATCH] 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 --- .../PhabricatorNotificationPanelController.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/applications/notification/controller/PhabricatorNotificationPanelController.php b/src/applications/notification/controller/PhabricatorNotificationPanelController.php index ea8ab702f3..2815101fb2 100644 --- a/src/applications/notification/controller/PhabricatorNotificationPanelController.php +++ b/src/applications/notification/controller/PhabricatorNotificationPanelController.php @@ -30,16 +30,9 @@ final class PhabricatorNotificationPanelController $stories = $query->execute(); - $num_unconsumed = 0; if ($stories) { $builder = new PhabricatorNotificationBuilder($stories); $notifications_view = $builder->buildView(); - - foreach ($stories as $story) { - if (!$story->getHasViewed()) { - $num_unconsumed++; - } - } $content = $notifications_view->render(); } else { $content = @@ -58,9 +51,12 @@ final class PhabricatorNotificationPanelController 'View All Notifications'). ''; + $unread_count = id(new PhabricatorFeedStoryNotification()) + ->countUnread($user); + $json = array( 'content' => $content, - 'number' => $num_unconsumed, + 'number' => $unread_count, ); return id(new AphrontAjaxResponse())->setContent($json);