diff --git a/CHANGELOG.md b/CHANGELOG.md index 6295e9154d88d69382c25f6c220bdba7a7e01cd1..67d4fb8075baf56b5b403277e2faf9f1befc49ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,7 +18,9 @@ yet implemented. - Make player metadata, title and show name as links [#167](https://git.project-insanity.org/onny/nextcloud-app-podcast/-/issues/167) @onny - Add pagination to listening and library view - [#195](https://git.project-insanity.org/onny/nextcloud-app-podcast/-/issues/195) @onny + [#195](https://git.project-insanity.org/onny/nextcloud-app-podcast/-/issues/195) @onny +- Show newest podcasts and episodes in library view + [#214](https://git.project-insanity.org/onny/nextcloud-app-podcast/-/issues/214) @onny ### Changed - Update npm modules diff --git a/lib/Controller/EpisodeController.php b/lib/Controller/EpisodeController.php index 5bac083f2d11714f87b43c68cd8eb5e4ecadfc73..a2227eecf930662a8109c501c76001676b04e712 100644 --- a/lib/Controller/EpisodeController.php +++ b/lib/Controller/EpisodeController.php @@ -58,7 +58,7 @@ class EpisodeController extends Controller { * @NoAdminRequired */ public function index(int $episode_id = null, int $podcast_id = null, - int $count = 20, int $page = 0): DataResponse { + int $count = 20, int $page = 0, string $sortBy = null): DataResponse { if ($episode_id) { return new DataResponse($this->fyydapi->queryEpisode($episode_id)); @@ -66,7 +66,7 @@ class EpisodeController extends Controller { return new DataResponse($this->fyydapi->queryEpisodes($podcast_id, $count, $page)); } - $data = $this->service->findAll($this->userId); + $data = $this->service->findAll($this->userId, $sortBy); $data = array_slice($data, $page * $count, $count); if (count($data) == $count) { diff --git a/lib/Controller/ShowController.php b/lib/Controller/ShowController.php index d55271f72280f58031029fb3aaa59558cad2514b..40e67bafc9cae4b112e48360d4ef1898a288655f 100644 --- a/lib/Controller/ShowController.php +++ b/lib/Controller/ShowController.php @@ -98,22 +98,22 @@ class ShowController extends Controller { /** * @NoAdminRequired */ - public function create(int $id, string $imgurl, string $author, + public function create(int $id, string $smallImageURL, string $author, string $title, string $lastpub, int $dateadded, string $homepage, string $feedurl): DataResponse { - return new DataResponse($this->service->create($id, $imgurl, $author, + return new DataResponse($this->service->create($id, $smallImageURL, $author, $title, $lastpub, $dateadded, $homepage, $feedurl, $this->userId)); } /** * @NoAdminRequired */ - public function update(int $id, string $imgurl, string $author, + public function update(int $id, string $smallImageURL, string $author, string $title, string $lastpub, int $dateadded, string $homepage, string $feedurl): DataResponse { - return $this->handleNotFound(function () use ($id, $imgurl, $author, + return $this->handleNotFound(function () use ($id, $smallImageURL, $author, $title, $lastpub, $dateadded, $homepage, $feedurl) { - return $this->service->update($id, $imgurl, $author, $title, $lastpub, + return $this->service->update($id, $smallImageURL, $author, $title, $lastpub, $dateadded, $homepage, $feedurl, $this->userId); }); } diff --git a/lib/Db/EpisodeMapper.php b/lib/Db/EpisodeMapper.php index db5fabd9a99c14cb91d91594a9b7a6f4f023db12..fdb7a355ee52a78b6d15448d6dfa9ec55e650dc8 100644 --- a/lib/Db/EpisodeMapper.php +++ b/lib/Db/EpisodeMapper.php @@ -55,12 +55,21 @@ class EpisodeMapper extends QBMapper { * @param string $userId * @return array */ - public function findAll(string $userId): array { + public function findAll(string $userId, string $sortBy = null): array { + if ($sortBy) { + if ($sortBy == 'pubdate') { + $sortBy = 'pubdate'; + } else { + $sortBy = 'lastplayed'; + } + } else { + $sortBy = 'lastplayed'; + }; /* @var $qb IQueryBuilder */ $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from('episodes') - ->orderBy('lastplayed', 'DESC') + ->orderBy($sortBy, 'DESC') ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); return $this->findEntities($qb); } diff --git a/lib/Db/ShowMapper.php b/lib/Db/ShowMapper.php index 9fb06389da447d9120f5f2f69a6922ba710cb812..6a94199bd0083df75f287149f57c609e8a39e91b 100644 --- a/lib/Db/ShowMapper.php +++ b/lib/Db/ShowMapper.php @@ -61,7 +61,7 @@ class ShowMapper extends QBMapper { $qb = $this->db->getQueryBuilder(); $qb->select('*') ->from('shows') - ->orderBy('dateadded', 'DESC') + ->orderBy('lastpub', 'DESC') ->where($qb->expr()->eq('user_id', $qb->createNamedParameter($userId))); return $this->findEntities($qb); } diff --git a/lib/Service/EpisodeService.php b/lib/Service/EpisodeService.php index c0f2217424b3432194bf0b9ff351563ca8bf826f..06cfd39ccab5662ca50654fe14788406b1625473 100644 --- a/lib/Service/EpisodeService.php +++ b/lib/Service/EpisodeService.php @@ -40,8 +40,8 @@ class EpisodeService { $this->mapper = $mapper; } - public function findAll(string $userId): array { - return $this->mapper->findAll($userId); + public function findAll(string $userId, string $sortBy = null): array { + return $this->mapper->findAll($userId, $sortBy); } private function handleException(Exception $e): void { diff --git a/src/services/EpisodeApi.js b/src/services/EpisodeApi.js index 99860c444765d0cea00ff143506ea856b2e99b8a..c95c08244cbdc0a91a2f898e2c8c33bd1db9ce00 100644 --- a/src/services/EpisodeApi.js +++ b/src/services/EpisodeApi.js @@ -72,7 +72,7 @@ export class EpisodeApi { }) } - queryEpisodes(podcastId = null, page = 0) { + queryEpisodes(podcastId = null, page = 0, sortBy = 'lastplayed') { let params = {} if (podcastId) { params = { @@ -84,6 +84,7 @@ export class EpisodeApi { params = { count: 20, page, + sortBy, } } return axios.get(this.url('/episodes'), { diff --git a/src/views/Library.vue b/src/views/Library.vue index 497643feefecfb9f8f505eb29fb5a01443a7a849..138fab39e9c209b09615ea3a7e65b646c4051f1e 100644 --- a/src/views/Library.vue +++ b/src/views/Library.vue @@ -109,7 +109,7 @@ export default { }, async queryEpisodes(page) { - const episodes = await episodeApiClient.queryEpisodes(null, page) + const episodes = await episodeApiClient.queryEpisodes(null, page, 'pubdate') this.episodes = this.episodes.concat(episodes.data.episodes) if (episodes.meta.paging.next_page === null) { this.page = null diff --git a/src/views/Listening.vue b/src/views/Listening.vue index c799fd4a3f17b3ecac74561fd79576e8e88401e2..1a58271ef90da845fe7d75bf29fef15e377ce492 100644 --- a/src/views/Listening.vue +++ b/src/views/Listening.vue @@ -69,7 +69,7 @@ export default { ]), async queryEpisodes(page) { - const episodes = await episodeApiClient.queryEpisodes(null, page) + const episodes = await episodeApiClient.queryEpisodes(null, page, 'lastplayed') this.episodes = this.episodes.concat(episodes.data.episodes) if (episodes.meta.paging.next_page === null) { this.page = null