diff options
-rw-r--r-- | ajax/setallitemsread.php | 7 | ||||
-rw-r--r-- | js/menu.js | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/ajax/setallitemsread.php b/ajax/setallitemsread.php index b24d62262..f6d206e20 100644 --- a/ajax/setallitemsread.php +++ b/ajax/setallitemsread.php @@ -44,11 +44,14 @@ $success = false; if($mostRecentItemId !== 0) { $mostRecentItem = $itemMapper->findById($mostRecentItemId); } + +$unreadCount = count($items); foreach($items as $item) { // FIXME: this should compare the modified date if($mostRecentItemId === 0 || $item->getDate() <= $mostRecentItem->getDate()) { $item->setRead(); - $success = $itemMapper->update($item); + $success = $itemMapper->update($item); + $unreadCount--; } } @@ -63,4 +66,4 @@ if(!$success) { } //TODO: replace the following with a real success case. see contact/ajax/createaddressbook.php for inspirations -OCP\JSON::success(array('data' => array('feedId' => $feedId ))); +OCP\JSON::success(array('data' => array('feedId' => $feedId, 'unreadCount' => $unreadCount))); diff --git a/js/menu.js b/js/menu.js index eaef655c3..90c623f6f 100644 --- a/js/menu.js +++ b/js/menu.js @@ -590,7 +590,7 @@ var News = News || {}; $.post(OC.filePath('news', 'ajax', 'setallitemsread.php'), data, function(jsonData) { if(jsonData.status == 'success'){ - self._updateUnreadCountAll(); + self._setUnreadCount(type, id, parseInt(jsonData.data.unreadCount)); } else { OC.dialogs.alert(jsonData.data.message, t('news', 'Error')); } |