|
9 | 9 | <VChip
|
10 | 10 | size="small"
|
11 | 11 | class="ma-2 hidden-sm-and-down">
|
12 |
| - <template v-if="loading"> |
13 |
| - {{ t('lazyLoading', { value: lazyLoadLimit }) }} |
| 12 | + <template v-if="!fullQueryIsCached"> |
| 13 | + {{ t('lazyLoading', { value: items.length }) }} |
14 | 14 | </template>
|
15 | 15 | <template v-else>
|
16 | 16 | {{ items?.length ?? 0 }}
|
@@ -73,7 +73,7 @@ import { getItemsApi } from '@jellyfin/sdk/lib/utils/api/items-api';
|
73 | 73 | import { getMusicGenresApi } from '@jellyfin/sdk/lib/utils/api/music-genres-api';
|
74 | 74 | import { getPersonsApi } from '@jellyfin/sdk/lib/utils/api/persons-api';
|
75 | 75 | import { getStudiosApi } from '@jellyfin/sdk/lib/utils/api/studios-api';
|
76 |
| -import { computed, onMounted, ref, shallowRef } from 'vue'; |
| 76 | +import { computed, onBeforeMount, ref, shallowRef } from 'vue'; |
77 | 77 | import { useI18n } from 'vue-i18n';
|
78 | 78 | import { useRoute } from 'vue-router/auto';
|
79 | 79 |
|
@@ -222,16 +222,15 @@ const { loading, data: queryItems } = await useBaseItem(api, method)(() => ({
|
222 | 222 | limit: queryLimit.value
|
223 | 223 | }));
|
224 | 224 |
|
225 |
| -const items = computed(() => { |
226 |
| - return queryLimit.value ? queryItems.value : [...(apiStore.getItemsById(lazyLoadIds.value) as BaseItemDto[]), ...queryItems.value]; |
227 |
| -}); |
| 225 | +const fullQueryIsCached = computed(() => loading.value ? !queryLimit.value && queryItems.value.length > lazyLoadLimit : true); |
| 226 | +const items = computed(() => fullQueryIsCached.value ? [...(apiStore.getItemsById(lazyLoadIds.value) as BaseItemDto[]), ...queryItems.value] : queryItems.value); |
228 | 227 |
|
229 | 228 | route.meta.title = library.value.Name;
|
230 | 229 |
|
231 | 230 | /**
|
232 | 231 | * We fetch the 1st 100 items and, after mount, we fetch the rest.
|
233 | 232 | */
|
234 |
| -onMounted(() => { |
| 233 | +onBeforeMount(() => { |
235 | 234 | lazyLoadIds.value = queryItems.value.map((i) => i.Id as string);
|
236 | 235 | queryLimit.value = undefined;
|
237 | 236 | });
|
|
0 commit comments