Use DI for tq everywhere

Signed-off-by: Varun Patil <varunpatil@ucla.edu>
pull/563/head
Varun Patil 2023-03-23 11:16:28 -07:00
parent f284085a1a
commit bd6aaeee3a
3 changed files with 11 additions and 15 deletions

View File

@ -55,7 +55,8 @@ abstract class GenericApiController extends Controller
IDBConnection $connection, IDBConnection $connection,
IRootFolder $rootFolder, IRootFolder $rootFolder,
IAppManager $appManager, IAppManager $appManager,
LoggerInterface $logger LoggerInterface $logger,
TimelineQuery $timelineQuery
) { ) {
parent::__construct(Application::APPNAME, $request); parent::__construct(Application::APPNAME, $request);
@ -65,6 +66,6 @@ abstract class GenericApiController extends Controller
$this->rootFolder = $rootFolder; $this->rootFolder = $rootFolder;
$this->appManager = $appManager; $this->appManager = $appManager;
$this->logger = $logger; $this->logger = $logger;
$this->timelineQuery = new TimelineQuery($connection); $this->timelineQuery = $timelineQuery;
} }
} }

View File

@ -12,7 +12,6 @@ use OCP\AppFramework\Services\IInitialState;
use OCP\EventDispatcher\IEventDispatcher; use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder; use OCP\Files\IRootFolder;
use OCP\IConfig; use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IURLGenerator; use OCP\IURLGenerator;
use OCP\IUserSession; use OCP\IUserSession;
use OCP\Util; use OCP\Util;
@ -24,7 +23,6 @@ class PublicAlbumController extends Controller
protected IInitialState $initialState; protected IInitialState $initialState;
protected IAppManager $appManager; protected IAppManager $appManager;
protected IConfig $config; protected IConfig $config;
protected IDBConnection $connection;
protected IUserSession $userSession; protected IUserSession $userSession;
protected IRootFolder $rootFolder; protected IRootFolder $rootFolder;
protected IURLGenerator $urlGenerator; protected IURLGenerator $urlGenerator;
@ -36,21 +34,20 @@ class PublicAlbumController extends Controller
IInitialState $initialState, IInitialState $initialState,
IAppManager $appManager, IAppManager $appManager,
IConfig $config, IConfig $config,
IDBConnection $connection,
IUserSession $userSession, IUserSession $userSession,
IRootFolder $rootFolder, IRootFolder $rootFolder,
IURLGenerator $urlGenerator IURLGenerator $urlGenerator,
TimelineQuery $timelineQuery
) { ) {
$this->appName = $appName; $this->appName = $appName;
$this->eventDispatcher = $eventDispatcher; $this->eventDispatcher = $eventDispatcher;
$this->initialState = $initialState; $this->initialState = $initialState;
$this->appManager = $appManager; $this->appManager = $appManager;
$this->config = $config; $this->config = $config;
$this->connection = $connection;
$this->userSession = $userSession; $this->userSession = $userSession;
$this->rootFolder = $rootFolder; $this->rootFolder = $rootFolder;
$this->urlGenerator = $urlGenerator; $this->urlGenerator = $urlGenerator;
$this->timelineQuery = new TimelineQuery($this->connection); $this->timelineQuery = $timelineQuery;
} }
/** /**

View File

@ -13,7 +13,6 @@ use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder; use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException; use OCP\Files\NotFoundException;
use OCP\IConfig; use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IRequest; use OCP\IRequest;
use OCP\ISession; use OCP\ISession;
use OCP\IURLGenerator; use OCP\IURLGenerator;
@ -33,8 +32,8 @@ class PublicController extends AuthPublicShareController
protected IShareManager $shareManager; protected IShareManager $shareManager;
protected IUserManager $userManager; protected IUserManager $userManager;
protected IAppManager $appManager; protected IAppManager $appManager;
protected IDBConnection $db;
protected IConfig $config; protected IConfig $config;
protected TimelineQuery $timelineQuery;
protected IShare $share; protected IShare $share;
@ -50,8 +49,8 @@ class PublicController extends AuthPublicShareController
IShareManager $shareManager, IShareManager $shareManager,
IUserManager $userManager, IUserManager $userManager,
IAppManager $appManager, IAppManager $appManager,
IDBConnection $db, IConfig $config,
IConfig $config TimelineQuery $timelineQuery
) { ) {
parent::__construct($AppName, $request, $session, $urlGenerator); parent::__construct($AppName, $request, $session, $urlGenerator);
$this->eventDispatcher = $eventDispatcher; $this->eventDispatcher = $eventDispatcher;
@ -61,8 +60,8 @@ class PublicController extends AuthPublicShareController
$this->shareManager = $shareManager; $this->shareManager = $shareManager;
$this->userManager = $userManager; $this->userManager = $userManager;
$this->appManager = $appManager; $this->appManager = $appManager;
$this->db = $db;
$this->config = $config; $this->config = $config;
$this->timelineQuery = $timelineQuery;
} }
/** /**
@ -257,8 +256,7 @@ class PublicController extends AuthPublicShareController
/** Get initial state of single item */ /** Get initial state of single item */
private function getSingleItemInitialState(\OCP\Files\File $file): string private function getSingleItemInitialState(\OCP\Files\File $file): string
{ {
$timelineQuery = new TimelineQuery($this->db); $photo = $this->timelineQuery->getSingleItem($file->getId());
$photo = $timelineQuery->getSingleItem($file->getId());
return json_encode($photo); return json_encode($photo);
} }