summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ajax/updatefeed.php17
-rw-r--r--css/news.css2
-rw-r--r--js/news.js9
3 files changed, 20 insertions, 8 deletions
diff --git a/ajax/updatefeed.php b/ajax/updatefeed.php
index bc74324e3..f503d9e91 100644
--- a/ajax/updatefeed.php
+++ b/ajax/updatefeed.php
@@ -33,7 +33,16 @@ if(!$newfeedid) {
OCP\Util::writeLog('news','ajax/updatefeed.php: Error updating feed: '.$_POST['feedid'], OCP\Util::ERROR);
exit();
}
-
-//TODO: replace the following with a real success case. see contact/ajax/createaddressbook.php for inspirations
-OCP\JSON::success(array('data' => array('message' => $l->t('Feed updated!'))));
-
+else {
+ //TODO: maybe make this more efficient by coding it into OC_News_FeedMapper->save()
+ $itemmapper = new OC_News_ItemMapper();
+ $items = $itemmapper->findAll($newfeedid);
+ $unreadcounter = 0;
+ foreach($items as $item) {
+ if(!$item->isRead())
+ ++$unreadcounter;
+ }
+
+ OCP\JSON::success(array('data' => array('message' => $l->t('Feed updated!'), 'unreadcount' => $unreadcounter)));
+ exit();
+}
diff --git a/css/news.css b/css/news.css
index 61cb8c001..81141252a 100644
--- a/css/news.css
+++ b/css/news.css
@@ -17,7 +17,7 @@
#addfeed { background: url('%appswebroot%/apps/news/img/rss.svg') no-repeat left center; padding-left: 20px !important; }
#unreaditemcounter.nonzero { position: relative; background: #5E5E5E; border-radius: 5px; padding: 0 5px; color: white; text-align: center; margin: 0 0.3em 0 0.3em;}
-#unreaditemcounter.zero { position: relative; margin: 0 0.3em 0 0.3em;}
+#unreaditemcounter.zero { position: relative; margin: 0 0.3em 0 0;}
ul.controls li { float: left; }
diff --git a/js/news.js b/js/news.js
index f2c5703f7..16dae8e57 100644
--- a/js/news.js
+++ b/js/news.js
@@ -188,11 +188,14 @@ News={
counterplace.html('<img src="' + OC.imagePath('core','loader.gif') + '" alt="refresh" />');
$.post(OC.filePath('news', 'ajax', 'updatefeed.php'),{'feedid':feedid, 'feedurl':feedurl, 'folderid':folderid},function(jsondata){
if(jsondata.status == 'success'){
- var newcount = oldcount;
+ var newcount = jsondata.data.unreadcount;
if (newcount > 0) {
counterplace.addClass('nonzero');
+ counterplace.html(newcount);
+ }
+ else {
+ counterplace.html('');
}
- counterplace.html(newcount);
}
else{
if (oldcount > 0) {
@@ -257,7 +260,7 @@ $(document).ready(function(){
setupFeedList();
News.Feed.updateAll();
- var updateInterval = 20000; //how often the feeds should update (in msec)
+ var updateInterval = 200000; //how often the feeds should update (in msec)
setInterval('News.Feed.updateAll()', updateInterval);
});