summaryrefslogtreecommitdiffstats
path: root/controller/feedcontroller.php
diff options
context:
space:
mode:
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);
}