summaryrefslogtreecommitdiffstats
path: root/controller/feedcontroller.php
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2013-04-29 13:25:04 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2013-04-29 13:30:01 +0200
commit3fc18156ae0b586e8de0c82949acfa6291317536 (patch)
tree201e97511bea44c58b5e9d78d8cf36ae2e2b54f9 /controller/feedcontroller.php
parenta03b54c6a59837d0045c140ea7aef3fae95daa95 (diff)
go back to order by id, fix #138, use a newest item id to prevent marking items as read that the user didnt see yet fix #141, also update the starred count periodically
Diffstat (limited to 'controller/feedcontroller.php')
-rw-r--r--controller/feedcontroller.php18
1 files changed, 15 insertions, 3 deletions
diff --git a/controller/feedcontroller.php b/controller/feedcontroller.php
index 09f638170..d19008b5a 100644
--- a/controller/feedcontroller.php
+++ b/controller/feedcontroller.php
@@ -29,6 +29,7 @@ use \OCA\AppFramework\Controller\Controller;
use \OCA\AppFramework\Core\API;
use \OCA\AppFramework\Http\Request;
+use \OCA\News\BusinessLayer\ItemBusinessLayer;
use \OCA\News\BusinessLayer\FeedBusinessLayer;
use \OCA\News\BusinessLayer\FolderBusinessLayer;
use \OCA\News\BusinessLayer\BusinessLayerException;
@@ -39,13 +40,16 @@ class FeedController extends Controller {
private $feedBusinessLayer;
private $folderBusinessLayer;
+ private $itemBusinessLayer;
public function __construct(API $api, Request $request,
FeedBusinessLayer $feedBusinessLayer,
- FolderBusinessLayer $folderBusinessLayer){
+ FolderBusinessLayer $folderBusinessLayer,
+ ItemBusinessLayer $itemBusinessLayer){
parent::__construct($api, $request);
$this->feedBusinessLayer = $feedBusinessLayer;
$this->folderBusinessLayer = $folderBusinessLayer;
+ $this->itemBusinessLayer = $itemBusinessLayer;
}
@@ -56,12 +60,20 @@ class FeedController extends Controller {
*/
public function feeds(){
$userId = $this->api->getUserId();
- $result = $this->feedBusinessLayer->findAll($userId);
+ // this method is also used to update the interface
+ // because of this we also pass the starred count and the newest
+ // item id which will be used for marking feeds read
$params = array(
- 'feeds' => $result
+ 'feeds' => $this->feedBusinessLayer->findAll($userId),
+ 'starred' => $this->itemBusinessLayer->starredCount($userId)
);
+ try {
+ $params['newestItemId'] =
+ $this->itemBusinessLayer->getNewestItemId($userId);
+ } catch (BusinessLayerException $ex) {}
+
return $this->renderJSON($params);
}