Skip to content

Commit 5dec105

Browse files
committed
fix(buttons): pass down loading state from items
1 parent 1e17f46 commit 5dec105

11 files changed

+38
-11
lines changed

src/components/common/list/ListButtonCheckin.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useI18n } from '~/utils/i18n.utils';
1515
1616
const { disabled, item } = defineProps<{
1717
disabled?: boolean;
18+
loading?: boolean;
1819
item?: ListScrollItem;
1920
buttonProps?: ButtonProps;
2021
iconProps?: IconProps;
@@ -56,13 +57,13 @@ const onClick = async () => {
5657
}
5758
};
5859
59-
const { loading } = useWatchingStoreRefs();
60+
const { loading: watchLoading } = useWatchingStoreRefs();
6061
</script>
6162

6263
<template>
6364
<ListButton
6465
:disabled="disabled"
65-
:loading="loading"
66+
:loading="loading || watchLoading"
6667
:colored="watching"
6768
:button-props="{ type: 'error', ...buttonProps }"
6869
:icon-props="{ component: watching ? IconCancel : IconConfirmCircle, ...iconProps }"

src/components/common/list/ListButtonCollected.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ const props = defineProps({
3737
type: Boolean,
3838
required: false,
3939
},
40+
loading: {
41+
type: Boolean,
42+
required: false,
43+
},
4044
disableFetch: {
4145
type: Boolean,
4246
required: false,
@@ -55,7 +59,7 @@ const emit = defineEmits<{
5559
(e: 'onClick', payload: { query: AddOrRemoveQuery; request: Promise<unknown> }): void;
5660
}>();
5761
58-
const { disabled, disableFetch, item, dateType } = toRefs(props);
62+
const { disabled, disableFetch, item, dateType, loading } = toRefs(props);
5963
6064
const { collected, date: dateCollected } = useItemCollected(item);
6165
@@ -76,6 +80,7 @@ const { loadingCollected } = useMovieStoreRefs();
7680
const { getShowCollectionLoading } = useShowStore();
7781
7882
const isLoading = computed(() => {
83+
if (loading?.value) return true;
7984
if (isListLoading.value) return true;
8085
if (item.value.type === 'movie') return loadingCollected.value;
8186
if (!item.value?.meta?.ids?.show?.trakt) return false;

src/components/common/list/ListButtonList.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const props = defineProps({
3131
type: Boolean,
3232
required: false,
3333
},
34+
loading: {
35+
type: Boolean,
36+
required: false,
37+
},
3438
disableFetch: {
3539
type: Boolean,
3640
required: false,
@@ -52,12 +56,13 @@ const emit = defineEmits<{
5256
): void;
5357
}>();
5458
55-
const { disabled, disableFetch, item, list } = toRefs(props);
59+
const { disabled, disableFetch, item, list, loading } = toRefs(props);
5660
5761
const { isItemListLoading, addToOrRemoveFromList, isItemInList, fetchListItems } =
5862
useListStore();
5963
6064
const isLoading = computed(() => {
65+
if (loading.value) return true;
6166
if (!item.value?.id) return;
6267
if (!isListItemType(item.value.type)) return;
6368
return isItemListLoading({

src/components/common/list/ListButtonWatched.vue

+6-1
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ const props = defineProps({
3737
type: Boolean,
3838
required: false,
3939
},
40+
loading: {
41+
type: Boolean,
42+
required: false,
43+
},
4044
disableFetch: {
4145
type: Boolean,
4246
required: false,
@@ -55,7 +59,7 @@ const emit = defineEmits<{
5559
(e: 'onClick', payload: { query: AddOrRemoveQuery; request: Promise<unknown> }): void;
5660
}>();
5761
58-
const { disabled, disableFetch, item, dateType } = toRefs(props);
62+
const { disabled, disableFetch, item, dateType, loading } = toRefs(props);
5963
6064
const { played, date: datePlayed } = useItemPlayed(item);
6165
@@ -76,6 +80,7 @@ const { loadingWatched } = useMovieStoreRefs();
7680
const { getShowProgressLoading } = useShowStore();
7781
7882
const isLoading = computed(() => {
83+
if (loading?.value) return true;
7984
if (isListLoading.value) return true;
8085
if (item.value.type === 'movie') return loadingWatched.value;
8186
if (!item.value?.meta?.ids?.show?.trakt) return false;

src/components/common/list/ListButtons.vue

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const { item, disabled, route } = defineProps<{
2222
item: ListScrollItem;
2323
route: Route;
2424
disabled?: boolean;
25+
loading?: boolean;
2526
}>();
2627
2728
type Query<T extends QuickActions> = T extends typeof QuickAction.Checkin
@@ -68,6 +69,7 @@ const onClick = <T extends QuickActions>(
6869
v-if="actions?.[QuickAction.List] && list"
6970
:list="list"
7071
:disabled="disabled"
72+
:loading="loading"
7173
:disable-fetch="route === Route.Watchlist"
7274
:item="item"
7375
@on-click="e => onClick(QuickAction.List, e)"
@@ -76,19 +78,22 @@ const onClick = <T extends QuickActions>(
7678
v-if="actions?.[QuickAction.Collect]"
7779
:date-type="collectionDate"
7880
:disabled="disabled"
81+
:loading="loading"
7982
:item="item"
8083
@on-click="e => onClick(QuickAction.Collect, e)"
8184
/>
8285
<ListButtonWatched
8386
v-if="actions?.[QuickAction.Watch]"
8487
:date-type="watchedDate"
8588
:disabled="disabled"
89+
:loading="loading"
8690
:item="item"
8791
@on-click="e => onClick(QuickAction.Watch, e)"
8892
/>
8993
<ListButtonCheckin
9094
v-if="actions?.[QuickAction.Checkin] && isEpisodeOrMovie(item.type)"
9195
:disabled="disabled"
96+
:loading="loading"
9297
:item="item"
9398
@on-click="e => onClick(QuickAction.Checkin, e)"
9499
/>

src/components/common/list/ListItem.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,11 @@ const onClick = (e: MouseEvent | KeyboardEvent) =>
343343
>
344344
<slot
345345
name="buttons"
346+
:item="item"
346347
:open="open"
347348
:dragged="dragged"
348349
:focusin="focusin"
349-
:item="item"
350+
:loading="loading"
350351
/>
351352
</NButtonGroup>
352353
</NFlex>

src/components/views/calendar/CalendarComponent.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,11 @@ const { onItemClick } = usePanelItem();
9191
@on-scroll-top="onScrollTop"
9292
@on-scroll-bottom="onScrollBottom"
9393
>
94-
<template #buttons="{ open, item }">
94+
<template #buttons="{ open, item, loading: itemLoading }">
9595
<ListButtons
9696
v-if="isListItemType(item?.type)"
9797
:disabled="!open"
98+
:loading="itemLoading"
9899
:item="item"
99100
:route="Route.Calendar"
100101
/>

src/components/views/history/HistoryComponent.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,11 @@ useActiveAndDocumentVisible({
9898
@onload-more="onLoadMore"
9999
@on-item-click="onItemClick"
100100
>
101-
<template #buttons="{ open, item }">
101+
<template #buttons="{ open, item, loading: itemLoading }">
102102
<ListButtons
103103
v-if="isListItemType(item?.type)"
104104
:disabled="!open"
105+
:loading="itemLoading"
105106
:item="item"
106107
:route="Route.History"
107108
/>

src/components/views/progress/ProgressComponent.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,11 @@ useActiveAndDocumentVisible({
119119
@on-scroll-top="scrolled = false"
120120
@on-item-click="onItemClick"
121121
>
122-
<template #buttons="{ open, item }">
122+
<template #buttons="{ open, item, loading: itemLoading }">
123123
<ListButtons
124124
v-if="isListItemType(item?.type)"
125125
:disabled="!open"
126+
:loading="itemLoading"
126127
:item="item"
127128
:route="Route.Progress"
128129
/>

src/components/views/search/SearchComponent.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,11 @@ const { onItemClick } = usePanelItem();
7070
@on-scroll-bottom="onScroll"
7171
@on-item-click="onItemClick"
7272
>
73-
<template #buttons="{ open, item }">
73+
<template #buttons="{ open, item, loading: itemLoading }">
7474
<ListButtons
7575
v-if="isListItemType(item?.type)"
7676
:disabled="!open"
77+
:loading="itemLoading"
7778
:item="item"
7879
:route="Route.Search"
7980
/>

src/components/views/watchlist/WatchlistComponent.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,11 @@ useActiveAndDocumentVisible({
117117
@onload-more="onLoadMore"
118118
@on-item-click="onItemClick"
119119
>
120-
<template #buttons="{ open, item }">
120+
<template #buttons="{ open, item, loading: itemLoading }">
121121
<ListButtons
122122
v-if="isListItemType(item?.type)"
123123
:disabled="!open"
124+
:loading="itemLoading"
124125
:item="item"
125126
:route="Route.Watchlist"
126127
@on-click="onButtonClick"

0 commit comments

Comments
 (0)