summaryrefslogtreecommitdiffstats
path: root/ajax
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2012-08-16 19:19:43 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2012-08-16 19:19:43 +0200
commitd8f94937ebc3fdfef7346033db26a77eebe5b93b (patch)
tree22b14e05c7c32fcafb0d0205ed5da486b81e6b90 /ajax
parent0241ac70ab58f00ffadfc3b4c8276f8cc8afd2ac (diff)
fixed marking feeds as read
Diffstat (limited to 'ajax')
-rw-r--r--ajax/setallitemsread.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/ajax/setallitemsread.php b/ajax/setallitemsread.php
index c5b589481..b5fca1fd3 100644
--- a/ajax/setallitemsread.php
+++ b/ajax/setallitemsread.php
@@ -16,16 +16,20 @@ OCP\JSON::checkAppEnabled('news');
OCP\JSON::callCheck();
$feedId = $_POST['feedId'];
-$mostRecentItemId = $_POST['mostRecentItemId'];
+$mostRecentItemId = (int)$_POST['mostRecentItemId'];
$itemMapper = new OCA\News\ItemMapper();
+$mostRecentItem = $itemMapper->find($mostRecentItemId);
+//echo $mostRecentItem->getDate();
$items = $itemMapper->findAllStatus($feedId, OCA\News\StatusFlag::UNREAD);
// FIXME: maybe there is a way to set all items read in the
// FeedMapper instead of iterating through every item and updating as
// necessary
+$success = false;
foreach($items as $item){
- if($item->getId() <= $mostRecentItemId){
+ // FIXME: this should compare the modified date
+ if($item->getDate() <= $mostRecentItem->getDate()){
$item->setRead();
$success = $itemMapper->update($item);
}