Skip to content

Commit c7ad96b

Browse files
committed
fix(progress): eagerly fetch progress when item is in view
1 parent a3b9b28 commit c7ad96b

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

src/components/common/list/ListItemPanel.vue

+20-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
type PopoverProps,
1212
} from 'naive-ui';
1313
14-
import { computed, defineProps, type PropType, ref, toRefs } from 'vue';
14+
import { computed, defineProps, type PropType, ref, toRefs, watch } from 'vue';
1515
1616
import PosterPlaceholder from '~/assets/images/poster-placholder.webp';
1717
import AnchorLink from '~/components/common/buttons/AnchorLink.vue';
@@ -25,6 +25,7 @@ import { type ListScrollItem } from '~/models/list-scroll.model';
2525
2626
import { ProgressType } from '~/models/progress-type.model';
2727
import { useItemCollected, useItemPlayed } from '~/stores/composable/use-item-played';
28+
import { useShowStore } from '~/stores/data/show.store';
2829
import { useWatchingStore } from '~/stores/data/watching.store';
2930
import { useExtensionSettingsStoreRefs } from '~/stores/settings/extension.store';
3031
import { useLinksStore } from '~/stores/settings/links.store';
@@ -126,6 +127,24 @@ const {
126127
} = useItemPlayed(item, { showPlayed, showProgress });
127128
const { collected, date: collectedDate } = useItemCollected(item, showCollected);
128129
130+
const { fetchShowProgress } = useShowStore();
131+
132+
if (showProgress.value) {
133+
watch(
134+
item,
135+
() => {
136+
if (!showProgress.value) return;
137+
if (!item?.value?.getProgressQuery) return;
138+
const { id, cacheOptions } = item.value?.getProgressQuery() ?? {};
139+
if (!id) return;
140+
return fetchShowProgress(id.toString(), cacheOptions);
141+
},
142+
{
143+
immediate: true,
144+
},
145+
);
146+
}
147+
129148
const { isWatchingListItem } = useWatchingStore();
130149
const watching = computed(() => {
131150
if (!showWatching.value) return false;

0 commit comments

Comments
 (0)