зеркало из https://github.com/nextcloud/news.git
update counters with js when update feeds
This commit is contained in:
Родитель
f80555a94c
Коммит
96a44ed8e8
|
@ -33,7 +33,16 @@ if(!$newfeedid) {
|
|||
OCP\Util::writeLog('news','ajax/updatefeed.php: Error updating feed: '.$_POST['feedid'], OCP\Util::ERROR);
|
||||
exit();
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
//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!'))));
|
||||
|
||||
OCP\JSON::success(array('data' => array('message' => $l->t('Feed updated!'), 'unreadcount' => $unreadcounter)));
|
||||
exit();
|
||||
}
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
|
@ -188,12 +188,15 @@ 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('');
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (oldcount > 0) {
|
||||
counterplace.addClass('nonzero');
|
||||
|
@ -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);
|
||||
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче