summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2012-09-20 19:17:39 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2012-09-20 19:17:53 +0200
commit7492639549bbf67d89ccb41aa68416cacafaae7d (patch)
tree6fc85ed523cdde5c52d4d5a81beb1de65c7c8044
parent5ead2af71798670854217888ba178ba7861f2989 (diff)
setting items as read has now an immediate response from the server about how many feeds are unread and the ui updates nearly immediately
-rw-r--r--ajax/setallitemsread.php7
-rw-r--r--js/menu.js2
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'));
}