diff --git a/front/src/ui/modals/Search.vue b/front/src/ui/modals/Search.vue index 8b973c3c6..53a16dc41 100644 --- a/front/src/ui/modals/Search.vue +++ b/front/src/ui/modals/Search.vue @@ -9,9 +9,12 @@ import { trim, uniqBy } from 'lodash-es' import useErrorHandler from '~/composables/useErrorHandler' import { useI18n } from 'vue-i18n' import { useModal } from '~/ui/composables/useModal.ts' +import { useStore } from '~/store' import ArtistCard from '~/components/artist/Card.vue' import PlaylistCard from '~/components/playlists/Card.vue' +import ChannelCard from '~/components/audio/ChannelCard.vue' +import ActorLink from '~/components/common/ActorLink.vue' import TrackTable from '~/components/audio/track/Table.vue' import AlbumCard from '~/components/album/Card.vue' import RadioCard from '~/components/radios/Card.vue' @@ -279,6 +282,26 @@ watch(results, () => { openSections.value = new Set(categoriesWithResults.map(({ type }) => type)) }) +// Subscribe to an RSS feed + +const store = useStore() + +/** + * Subscribe to an RSS feed and return the route for the subscribed channel + * @param url The RSS feed URL + * @returns The route object for the subscribed channel + */ + const rssSubscribe = async (url: string) => { + try { + const response = await axios.post('channels/rss-subscribe/', { url }) + store.commit('channels/subscriptions', { uuid: response.data.channel.uuid, value: true }) + return response.data.channel + } catch (error) { + useErrorHandler(error as Error) + return null + } +} + // Search const search = async () => { @@ -324,13 +347,10 @@ const search = async () => { } else { // TODO: add (@)type key to Response type if (category.type === 'rss') { - const response = await axios.post( - category.endpoint, - { url: trimmedQuery.value } - ) - results.value.type = category.type - results.value.rss = [response.data] - responses.value[category.type] = response.data + const channel = await rssSubscribe(trimmedQuery.value) + if (channel) { + results.value.rss = [channel] // Store the subscribed channel + } } else if (category.type === 'federation') { const response = await axios.post( category.endpoint, @@ -406,8 +426,6 @@ const radioConfig = computed(() => // Start the search watch(queryDebounced, search, { immediate: true }) - -// TODO: Include redirectRoute function from RemoteSearchForm.vue and adapt to !results.value and results.value.type instead of objInfo - - {{ result.object?.full_username }} - + :actor="result.object" + />