fix: order properly episodes and search results
This commit is contained in:
parent
84f23d64d3
commit
b5007e672e
@ -33,7 +33,7 @@ class EpisodesController extends Controller
|
|||||||
|
|
||||||
$episodes = $this->episodeActionReader->parseRssXml((string) $feed->getBody());
|
$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)));
|
$episodes = array_intersect_key($episodes, array_unique(array_map(fn (EpisodeActionExtraData $episode) => $episode->getGuid(), $episodes)));
|
||||||
|
|
||||||
return new JSONResponse($episodes, $feed->getStatusCode());
|
return new JSONResponse($episodes, $feed->getStatusCode());
|
||||||
|
@ -65,7 +65,7 @@ export default {
|
|||||||
const currentSearch = this.value
|
const currentSearch = this.value
|
||||||
const feeds = await axios.get(generateUrl('/apps/repod/search?value={value}', { value: currentSearch }))
|
const feeds = await axios.get(generateUrl('/apps/repod/search?value={value}', { value: currentSearch }))
|
||||||
if (currentSearch === this.value) {
|
if (currentSearch === this.value) {
|
||||||
this.feeds = feeds.data
|
this.feeds = [...feeds.data].sort((a, b) => b.fetchedAtUnix - a.fetchedAtUnix)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
|
@ -93,7 +93,7 @@ export default {
|
|||||||
try {
|
try {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
const episodes = await axios.get(generateUrl('/apps/repod/episodes/list?url={url}', { url: this.url }))
|
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) {
|
} catch (e) {
|
||||||
console.error(e)
|
console.error(e)
|
||||||
showError(t('repod', 'Could not fetch episodes'))
|
showError(t('repod', 'Could not fetch episodes'))
|
||||||
|
Loading…
Reference in New Issue
Block a user