summaryrefslogtreecommitdiffstats
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
parent0241ac70ab58f00ffadfc3b4c8276f8cc8afd2ac (diff)
fixed marking feeds as read
-rw-r--r--ajax/setallitemsread.php8
-rw-r--r--js/news.js7
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() {