Skip to content

Commit 085c94d

Browse files
committed
Add POC media fetching and collection header
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent 4cc31b5 commit 085c94d

File tree

1 file changed

+54
-2
lines changed
  • frontend/src/pages/_mediaType/_collection

1 file changed

+54
-2
lines changed

frontend/src/pages/_mediaType/_collection/_.vue

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,29 @@
11
<template>
2-
<div class="px-6 lg:px-10"></div>
2+
<div class="px-6 lg:px-10">
3+
<VCollectionHeader
4+
v-if="collectionParams && collectionParams.collection"
5+
:title="collectionTitle"
6+
results-label="Lots of results"
7+
:collection="collectionParams.collection"
8+
/>
9+
<h1>{{ strategy }}</h1>
10+
<pre>{{ collectionParams }}</pre>
11+
<pre>{{ results }}</pre>
12+
</div>
313
</template>
414

515
<script lang="ts">
6-
import { defineComponent } from "@nuxtjs/composition-api"
16+
import { computed, ref } from "vue"
17+
import { defineComponent, useFetch } from "@nuxtjs/composition-api"
718
819
import { useProviderStore } from "~/stores/provider"
920
import { useSearchStore } from "~/stores/search"
1021
import { isSupportedMediaType, SupportedMediaType } from "~/constants/media"
1122
import type { Collection, CollectionParams } from "~/types/search"
1223
import { useFeatureFlagStore } from "~/stores/feature-flag"
1324
import { warn } from "~/utils/console"
25+
import { useMediaStore } from "~/stores/media"
26+
import { Media } from "~/types/media"
1427
1528
export default defineComponent({
1629
name: "VCollectionPage",
@@ -84,7 +97,46 @@ export default defineComponent({
8497
const searchStore = useSearchStore($pinia)
8598
searchStore.setStrategy(collection, collectionParams)
8699
searchStore.setSearchType(mediaType)
100+
87101
return true
88102
},
103+
setup() {
104+
const mediaStore = useMediaStore()
105+
const searchStore = useSearchStore()
106+
107+
const strategy = computed(() => searchStore.strategy)
108+
const collectionParams = computed(() => searchStore.collectionParams)
109+
110+
const collectionTitle = computed(() => {
111+
if (!collectionParams.value) return ""
112+
const collection = collectionParams.value.collection
113+
if (collection === "tag") {
114+
return collectionParams.value.tag
115+
} else if (collection === "source") {
116+
return collectionParams.value.source
117+
} else if (collection === "creator") {
118+
return collectionParams.value.creator
119+
} else {
120+
return ""
121+
}
122+
})
123+
124+
const results = ref<Media[]>([])
125+
126+
useFetch(async () => {
127+
if (isSupportedMediaType(mediaStore._searchType)) {
128+
await mediaStore.fetchMedia()
129+
results.value = mediaStore.resultItems[mediaStore._searchType]
130+
}
131+
})
132+
133+
return {
134+
strategy,
135+
collectionParams,
136+
collectionTitle,
137+
138+
results,
139+
}
140+
},
89141
})
90142
</script>

0 commit comments

Comments
 (0)