Skip to content

Commit c4be36e

Browse files
committed
Make isFetching a prop
Signed-off-by: Olga Bulat <obulat@gmail.com>
1 parent 0b6cb8e commit c4be36e

File tree

7 files changed

+35
-13
lines changed

7 files changed

+35
-13
lines changed

frontend/src/components/VSearchResultsGrid/VCollectionResults.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<VMediaCollection
33
:results="results"
4+
:is-fetching="isFetching"
45
:search-term="searchTerm"
56
:collection-label="collectionLabel"
67
kind="collection"
@@ -15,7 +16,7 @@
1516
/>
1617
</template>
1718

18-
<template #footer="{ isFetching }">
19+
<template #footer>
1920
<footer class="mb-6 mt-4 lg:mb-10">
2021
<VLoadMore
2122
:search-type="results.type"
@@ -59,6 +60,10 @@ export default defineComponent({
5960
type: Object as PropType<Results>,
6061
required: true,
6162
},
63+
isFetching: {
64+
type: Boolean,
65+
required: true,
66+
},
6267
searchTerm: {
6368
type: String,
6469
required: true,

frontend/src/components/VSearchResultsGrid/VMediaCollection.vue

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
:class="{ 'pt-2 sm:pt-0': results.type === 'image' }"
1616
/>
1717

18-
<slot name="footer" :is-fetching="_isFetching" />
18+
<slot name="footer" />
1919

2020
<VScrollButton
2121
v-show="showScrollButton"
@@ -30,7 +30,6 @@ import { computed, defineComponent, inject, type PropType, ref } from "vue"
3030
import type { Results } from "~/types/result"
3131
import { IsSidebarVisibleKey, ShowScrollButtonKey } from "~/types/provides"
3232
import { defineEvent } from "~/types/emits"
33-
import { useMediaStore } from "~/stores/media"
3433
3534
import VGridSkeleton from "~/components/VSkeleton/VGridSkeleton.vue"
3635
import VAllResultsGrid from "~/components/VSearchResultsGrid/VAllResultsGrid.vue"
@@ -74,6 +73,7 @@ export default defineComponent({
7473
*/
7574
isFetching: {
7675
type: Boolean,
76+
required: true,
7777
},
7878
},
7979
emits: {
@@ -83,13 +83,8 @@ export default defineComponent({
8383
const showScrollButton = inject(ShowScrollButtonKey, ref(false))
8484
const isSidebarVisible = inject(IsSidebarVisibleKey, ref(false))
8585
86-
const mediaStore = useMediaStore()
87-
const _isFetching = computed(
88-
() => props.isFetching ?? mediaStore.fetchState.isFetching
89-
)
90-
9186
const showSkeleton = computed(() => {
92-
return _isFetching.value && props.results.items.length === 0
87+
return props.isFetching && props.results.items.length === 0
9388
})
9489
9590
const component = computed(() => {
@@ -106,7 +101,6 @@ export default defineComponent({
106101
showSkeleton,
107102
showScrollButton,
108103
isSidebarVisible,
109-
_isFetching,
110104
component,
111105
}
112106
},

frontend/src/components/VSearchResultsGrid/VSearchResults.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<VMediaCollection
33
:collection-label="collectionLabel"
44
:results="results"
5+
:is-fetching="isFetching"
56
:search-term="searchTerm"
67
kind="search"
78
>
@@ -27,7 +28,7 @@
2728
/>
2829
</div>
2930
</template>
30-
<template #footer="{ isFetching }">
31+
<template #footer>
3132
<footer class="mb-6 mt-4 lg:mb-10">
3233
<VLoadMore
3334
:search-type="results.type"
@@ -83,6 +84,10 @@ export default defineComponent({
8384
type: Object as PropType<Results>,
8485
required: true,
8586
},
87+
isFetching: {
88+
type: Boolean,
89+
required: true,
90+
},
8691
},
8792
emits: {
8893
"load-more": defineEvent(),

frontend/src/pages/search.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<NuxtChild
1414
:key="$route.path"
1515
:results="searchResults"
16+
:is-fetching="isFetching"
1617
:search-term="searchTerm"
1718
:supported="supported"
1819
:handle-load-more="handleLoadMore"
@@ -143,6 +144,7 @@ export default defineComponent({
143144
}
144145
145146
const fetchingError = computed(() => fetchState.value.fetchingError)
147+
const isFetching = computed(() => fetchState.value.isFetching)
146148
147149
/**
148150
* Search middleware runs when the path changes. This watcher
@@ -206,6 +208,7 @@ export default defineComponent({
206208
207209
resultCount,
208210
searchResults,
211+
isFetching,
209212
fetchingError,
210213
211214
handleLoadMore,

frontend/src/pages/search/audio.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<template>
22
<VSearchResults
33
:results="results"
4-
kind="search"
4+
:is-fetching="isFetching"
55
:search-term="searchTerm"
6+
kind="search"
67
@load-more="handleLoadMore"
78
/>
89
</template>
@@ -24,6 +25,10 @@ export default defineComponent({
2425
type: Object as PropType<AudioResults>,
2526
required: true,
2627
},
28+
isFetching: {
29+
type: Boolean,
30+
required: true,
31+
},
2732
searchTerm: {
2833
type: String,
2934
required: true,

frontend/src/pages/search/image.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<template>
22
<VSearchResults
33
:results="results"
4-
kind="search"
4+
:is-fetching="isFetching"
55
:search-term="searchTerm"
6+
kind="search"
67
@load-more="handleLoadMore"
78
/>
89
</template>
@@ -22,6 +23,10 @@ export default defineComponent({
2223
type: Object as PropType<ImageResults>,
2324
required: true,
2425
},
26+
isFetching: {
27+
type: Boolean,
28+
required: true,
29+
},
2530
searchTerm: {
2631
type: String,
2732
required: true,

frontend/src/pages/search/index.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<VSearchResults
33
:results="results"
4+
:is-fetching="isFetching"
45
:search-term="searchTerm"
56
kind="search"
67
@load-more="handleLoadMore"
@@ -22,6 +23,10 @@ export default defineComponent({
2223
type: Object as PropType<AllMediaResults>,
2324
required: true,
2425
},
26+
isFetching: {
27+
type: Boolean,
28+
required: true,
29+
},
2530
searchTerm: {
2631
type: String,
2732
required: true,

0 commit comments

Comments
 (0)