diff options
Diffstat (limited to 'ajax/setallitemsread.php')
-rw-r--r-- | ajax/setallitemsread.php | 8 |
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); } |