diff --git a/frontend/src/components/VAudioDetails/VRelatedAudio.vue b/frontend/src/components/VAudioDetails/VRelatedAudio.vue
index d52420174d2..ff4e72878a4 100644
--- a/frontend/src/components/VAudioDetails/VRelatedAudio.vue
+++ b/frontend/src/components/VAudioDetails/VRelatedAudio.vue
@@ -1,5 +1,8 @@
-
diff --git a/frontend/src/components/VGlobalAudioSection/VGlobalAudioSection.vue b/frontend/src/components/VGlobalAudioSection/VGlobalAudioSection.vue
index 6ccaa38ef3c..8c2e5d5fdaf 100644
--- a/frontend/src/components/VGlobalAudioSection/VGlobalAudioSection.vue
+++ b/frontend/src/components/VGlobalAudioSection/VGlobalAudioSection.vue
@@ -51,8 +51,8 @@ export default defineComponent({
return audioFromMediaStore as AudioDetail
}
const singleResultStore = useSingleResultStore()
- if (singleResultStore.mediaItem?.id === trackId) {
- return singleResultStore.mediaItem as AudioDetail
+ if (singleResultStore.mediaId === trackId) {
+ return singleResultStore.audio
}
return null
}
diff --git a/frontend/src/components/VImageDetails/VRelatedImages.vue b/frontend/src/components/VImageDetails/VRelatedImages.vue
index 2d8d9d97833..d61913b3446 100644
--- a/frontend/src/components/VImageDetails/VRelatedImages.vue
+++ b/frontend/src/components/VImageDetails/VRelatedImages.vue
@@ -1,9 +1,8 @@
-
+
{{ $t("imageDetails.relatedImages") }}
-
diff --git a/frontend/src/components/VSearchResultsGrid/VImageGrid.vue b/frontend/src/components/VSearchResultsGrid/VImageGrid.vue
index c9eb4181a0f..31d61de5d3f 100644
--- a/frontend/src/components/VSearchResultsGrid/VImageGrid.vue
+++ b/frontend/src/components/VSearchResultsGrid/VImageGrid.vue
@@ -43,6 +43,8 @@ import VGridSkeleton from "~/components/VSkeleton/VGridSkeleton.vue"
import VLoadMore from "~/components/VLoadMore.vue"
import VImageCell from "~/components/VSearchResultsGrid/VImageCell.vue"
+import type { NuxtError } from "@nuxt/types"
+
export default defineComponent({
name: "ImageGrid",
components: { VGridSkeleton, VLoadMore, VImageCell },
@@ -62,7 +64,7 @@ export default defineComponent({
required: true,
},
fetchState: {
- type: Object as PropType,
+ type: Object as PropType>,
required: true,
},
imageGridLabel: {
@@ -74,7 +76,7 @@ export default defineComponent({
const searchStore = useSearchStore()
const searchTerm = computed(() => searchStore.searchTerm)
- const isError = computed(() => Boolean(props.fetchState.fetchingError))
+ const isError = computed(() => props.fetchState.fetchingError !== null)
const relatedTo = computed(() => {
return props.isSinglePage ? useRelatedMediaStore().mainMediaId : null
diff --git a/frontend/src/middleware/single-result.ts b/frontend/src/middleware/single-result.ts
index 7abc9461157..ca9f2f81b65 100644
--- a/frontend/src/middleware/single-result.ts
+++ b/frontend/src/middleware/single-result.ts
@@ -1,16 +1,42 @@
+import { useSingleResultStore } from "~/stores/media/single-result"
import { useSearchStore } from "~/stores/search"
+import { useRelatedMediaStore } from "~/stores/media/related-media"
+
+import { AUDIO, IMAGE } from "~/constants/media"
import type { Middleware } from "@nuxt/types"
-export const singleResultMiddleware: Middleware = ({ route, from, $pinia }) => {
- if (from && from.path.includes("/search/")) {
- const searchStore = useSearchStore($pinia)
- searchStore.setBackToSearchPath(from.fullPath)
- const searchTerm = Array.isArray(route.query.q)
- ? route.query.q[0]
- : route.query.q
- if (searchTerm) {
- searchStore.setSearchTerm(searchTerm)
+export const singleResultMiddleware: Middleware = async ({
+ route,
+ from,
+ error,
+ $pinia,
+}) => {
+ const mediaType = route.fullPath.includes("/image/") ? IMAGE : AUDIO
+ const singleResultStore = useSingleResultStore($pinia)
+
+ if (process.server) {
+ const media = await singleResultStore.fetch(mediaType, route.params.id)
+ await useRelatedMediaStore($pinia).fetchMedia(mediaType, route.params.id)
+
+ if (!media) {
+ error(singleResultStore.fetchState.fetchingError ?? {})
+ }
+ } else {
+ // Client-side rendering
+ singleResultStore.setMediaById(mediaType, route.params.id)
+
+ if (from && from.path.includes("/search/")) {
+ const searchStore = useSearchStore($pinia)
+ searchStore.setBackToSearchPath(from.fullPath)
+
+ const searchTerm = Array.isArray(route.query.q)
+ ? route.query.q[0]
+ : route.query.q
+
+ if (searchTerm) {
+ searchStore.setSearchTerm(searchTerm)
+ }
}
}
}
diff --git a/frontend/src/pages/audio/_id/index.vue b/frontend/src/pages/audio/_id/index.vue
index b96ab49c4f5..4ae3e5d0255 100644
--- a/frontend/src/pages/audio/_id/index.vue
+++ b/frontend/src/pages/audio/_id/index.vue
@@ -19,20 +19,21 @@
>
-
+
diff --git a/frontend/src/pages/image/_id/index.vue b/frontend/src/pages/image/_id/index.vue
index b62fadd23c7..6f0a37d3c0a 100644
--- a/frontend/src/pages/image/_id/index.vue
+++ b/frontend/src/pages/image/_id/index.vue
@@ -7,13 +7,19 @@
/>
-