From f26957a69ef6679a2b183273a60d04972d675a4c Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Tue, 22 Aug 2023 20:14:15 +0200 Subject: [PATCH] Fix front --- appinfo/routes.php | 6 +++--- img/fyyd.svg | 5 ----- img/itunes.svg | 4 ---- lib/Controller/FetchController.php | 10 +++++----- lib/Controller/SearchController.php | 2 +- src/components/Search.vue | 17 +++++------------ src/components/TopItem.vue | 14 +++++++------- src/components/TopList.vue | 10 +++++----- src/views/Feed.vue | 3 +-- 9 files changed, 27 insertions(+), 44 deletions(-) delete mode 100644 img/fyyd.svg delete mode 100644 img/itunes.svg diff --git a/appinfo/routes.php b/appinfo/routes.php index ec0fc03..89e6a4d 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -13,8 +13,8 @@ declare(strict_types=1); return [ 'routes' => [ ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'], - ['name' => 'fetch#index', 'url' => '/fetch/{uri}', 'verb' => 'GET'], - ['name' => 'search#index', 'url' => '/search/{value}', 'verb' => 'GET'], - ['name' => 'toplist#index', 'url' => '/toplist/{count}', 'verb' => 'GET'], + ['name' => 'fetch#index', 'url' => '/fetch', 'verb' => 'GET'], + ['name' => 'search#index', 'url' => '/search', 'verb' => 'GET'], + ['name' => 'toplist#index', 'url' => '/toplist', 'verb' => 'GET'], ], ]; diff --git a/img/fyyd.svg b/img/fyyd.svg deleted file mode 100644 index fe0be6c..0000000 --- a/img/fyyd.svg +++ /dev/null @@ -1,5 +0,0 @@ - - - \ No newline at end of file diff --git a/img/itunes.svg b/img/itunes.svg deleted file mode 100644 index 3f06156..0000000 --- a/img/itunes.svg +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/lib/Controller/FetchController.php b/lib/Controller/FetchController.php index 2a06b47..8448d93 100644 --- a/lib/Controller/FetchController.php +++ b/lib/Controller/FetchController.php @@ -24,16 +24,16 @@ class FetchController extends Controller parent::__construct(Application::APP_ID, $request); } - public function index(string $uri): JSONResponse + public function index(string $url): JSONResponse { - $podcastData = $this->podcastDataReader->getCachedOrFetchPodcastData($uri, $this->userService->getUserUID()); + $podcastData = $this->podcastDataReader->getCachedOrFetchPodcastData($url, $this->userService->getUserUID()); if ($podcastData) { - return new JSONResponse($podcastData->toArray()); + return new JSONResponse(['data' => $podcastData->toArray()]); } $client = $this->clientService->newClient(); - $feed = $client->get($uri); + $feed = $client->get($url); $statusCode = $feed->getStatusCode(); if ($statusCode < 200 || $statusCode >= 300) { @@ -42,6 +42,6 @@ class FetchController extends Controller $podcastData = PodcastData::parseRssXml((string) $feed->getBody()); - return new JSONResponse($podcastData->toArray()); + return new JSONResponse(['data' => $podcastData->toArray()]); } } diff --git a/lib/Controller/SearchController.php b/lib/Controller/SearchController.php index 4abdf68..c3b46a5 100644 --- a/lib/Controller/SearchController.php +++ b/lib/Controller/SearchController.php @@ -37,7 +37,7 @@ class SearchController extends Controller } } - usort($podcasts, fn (PodcastData $a, PodcastData $b) => $a->getFetchedAtUnix() <=> $b->getFetchedAtUnix()); + usort($podcasts, fn (PodcastData $a, PodcastData $b) => $b->getFetchedAtUnix() <=> $a->getFetchedAtUnix()); $podcasts = array_intersect_key($podcasts, array_unique(array_map(fn (PodcastData $feed) => $feed->getLink(), $podcasts))); return new JSONResponse($podcasts); diff --git a/src/components/Search.vue b/src/components/Search.vue index c26bd93..5a5e388 100644 --- a/src/components/Search.vue +++ b/src/components/Search.vue @@ -1,24 +1,18 @@ @@ -57,7 +51,7 @@ export default { search: debounce(async function value() { try { const currentSearch = this.value - const feeds = await axios.get(generateUrl('/apps/repod/search/{value}', { value: currentSearch })) + const feeds = await axios.get(generateUrl('/apps/repod/search?value={value}', { value: currentSearch })) if (currentSearch === this.value) { this.feeds = feeds.data } @@ -70,7 +64,6 @@ export default { return `/${btoa(url)}` }, formatTimeAgo, - generateUrl, }, } diff --git a/src/components/TopItem.vue b/src/components/TopItem.vue index ca8beda..38a5082 100644 --- a/src/components/TopItem.vue +++ b/src/components/TopItem.vue @@ -1,7 +1,7 @@ @@ -19,7 +19,11 @@ export default { type: String, required: true, }, - logo: { + imageUrl: { + type: String, + required: true, + }, + link: { type: String, required: true, }, @@ -27,15 +31,11 @@ export default { type: String, required: true, }, - url: { - type: String, - required: true, - }, }, methods: { async addSubscription() { try { - await axios.post(generateUrl('/apps/gpoddersync/subscription_change/create'), { add: [this.url], remove: [] }) + await axios.post(generateUrl('/apps/gpoddersync/subscription_change/create'), { add: [this.link], remove: [] }) } catch (e) { console.error(e) showError(t('Error while adding the feed')) diff --git a/src/components/TopList.vue b/src/components/TopList.vue index d13c762..71365c5 100644 --- a/src/components/TopList.vue +++ b/src/components/TopList.vue @@ -6,11 +6,11 @@

{{ t('Suggests by fyyd') }} @@ -40,7 +40,7 @@ export default { async mounted() { try { this.loading = true - const toplist = await axios.get(generateUrl('/apps/repod/toplist/10')) + const toplist = await axios.get(generateUrl('/apps/repod/toplist')) this.tops = toplist.data } catch (e) { console.error(e) diff --git a/src/views/Feed.vue b/src/views/Feed.vue index e74e1bc..f9ee4f8 100644 --- a/src/views/Feed.vue +++ b/src/views/Feed.vue @@ -15,7 +15,6 @@ {{ feed.author }} - {{ feed.description }}