From b5007e672ef7f6e1c185d4f243d6f1d44b95a4da Mon Sep 17 00:00:00 2001 From: Michel Roux Date: Sun, 14 Jan 2024 21:43:14 +0100 Subject: [PATCH] fix: order properly episodes and search results --- lib/Controller/EpisodesController.php | 2 +- src/components/Discover/Search.vue | 2 +- src/components/Feed/Episodes.vue | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Controller/EpisodesController.php b/lib/Controller/EpisodesController.php index dbd300e..74597b5 100644 --- a/lib/Controller/EpisodesController.php +++ b/lib/Controller/EpisodesController.php @@ -33,7 +33,7 @@ class EpisodesController extends Controller $episodes = $this->episodeActionReader->parseRssXml((string) $feed->getBody()); - usort($episodes, fn (EpisodeActionExtraData $a, EpisodeActionExtraData $b) => $b->getFetchedAtUnix() <=> $a->getFetchedAtUnix()); + usort($episodes, fn (EpisodeActionExtraData $a, EpisodeActionExtraData $b) => $b->getPubDate() <=> $a->getPubDate()); $episodes = array_intersect_key($episodes, array_unique(array_map(fn (EpisodeActionExtraData $episode) => $episode->getGuid(), $episodes))); return new JSONResponse($episodes, $feed->getStatusCode()); diff --git a/src/components/Discover/Search.vue b/src/components/Discover/Search.vue index 906ff0c..56cda0c 100644 --- a/src/components/Discover/Search.vue +++ b/src/components/Discover/Search.vue @@ -65,7 +65,7 @@ export default { const currentSearch = this.value const feeds = await axios.get(generateUrl('/apps/repod/search?value={value}', { value: currentSearch })) if (currentSearch === this.value) { - this.feeds = feeds.data + this.feeds = [...feeds.data].sort((a, b) => b.fetchedAtUnix - a.fetchedAtUnix) } } catch (e) { console.error(e) diff --git a/src/components/Feed/Episodes.vue b/src/components/Feed/Episodes.vue index 78ee639..4122d2a 100644 --- a/src/components/Feed/Episodes.vue +++ b/src/components/Feed/Episodes.vue @@ -93,7 +93,7 @@ export default { try { this.loading = true const episodes = await axios.get(generateUrl('/apps/repod/episodes/list?url={url}', { url: this.url })) - this.episodes = episodes.data + this.episodes = [...episodes.data].sort((a, b) => new Date(b.pubDate.date) - new Date(a.pubDate.date)) } catch (e) { console.error(e) showError(t('repod', 'Could not fetch episodes'))