diff options
-rw-r--r-- | ajax/setallitemsread.php | 8 | ||||
-rw-r--r-- | js/news.js | 7 |
2 files changed, 11 insertions, 4 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); } diff --git a/js/news.js b/js/news.js index dada15fb2..6dbfd14da 100644 --- a/js/news.js +++ b/js/news.js @@ -372,7 +372,7 @@ News={ // this array is used to store ids to prevent sending too // many posts when scrolling. the structure is: feed_id: boolean processing:{}, - activeFeedId: parseInt($('#rightcontent').data('id')), + activeFeedId: -1000, }, /** @@ -692,8 +692,9 @@ function bindItemEventListeners(){ }); // bind the mark all as read button + $('#mark_all_as_read').unbind(); $('#mark_all_as_read').click(function(){ - var feedId = $('.rightcontent').data('id'); + var feedId = News.Feed.activeFeedId; News.Feed.setAllItemsRead(feedId); }); @@ -701,6 +702,8 @@ function bindItemEventListeners(){ $(document).ready(function(){ + News.Feed.activeFeedId = parseInt($('#rightcontent').data('id')); + $('#addfeed_dialog_firstrun').hide(); $('#addfeed').click(function() { |