@@ -20,12 +20,10 @@ import ProgressTooltip from '~/components/common/tooltip/ProgressTooltip.vue';
20
20
import IconGrid from ' ~/components/icons/IconGrid.vue' ;
21
21
import IconPlayFilled from ' ~/components/icons/IconPlayFilled.vue' ;
22
22
import { getCustomLinkIcon } from ' ~/models/link.model' ;
23
- import { type ListScrollItem , type ShowProgress } from ' ~/models/list-scroll.model' ;
23
+ import { type ListScrollItem } from ' ~/models/list-scroll.model' ;
24
24
25
25
import { ProgressType } from ' ~/models/progress-type.model' ;
26
- import { useHistoryStore } from ' ~/stores/data/history.store' ;
27
- import { useMovieStore } from ' ~/stores/data/movie.store' ;
28
- import { useShowStore } from ' ~/stores/data/show.store' ;
26
+ import { useItemCollected , useItemPlayed } from ' ~/stores/composable/use-item-played' ;
29
27
import { useExtensionSettingsStoreRefs } from ' ~/stores/settings/extension.store' ;
30
28
import { useLinksStore } from ' ~/stores/settings/links.store' ;
31
29
import { useI18n } from ' ~/utils/i18n.utils' ;
@@ -113,127 +111,12 @@ const tags = computed(
113
111
}),
114
112
);
115
113
116
- const { getShowWatchedProgress, getShowCollectionProgress } = useShowStore ();
117
-
118
- const progress = computed <ShowProgress | undefined >(() => {
119
- if (! showProgress .value && ! showPlayed .value && ! showCollected .value ) return ;
120
- if (item ?.value ?.progress ) return item .value ?.progress ;
121
- if (item ?.value ?.progressRef ) return item .value ?.progressRef .value ;
122
- if (! item ?.value ?.getProgressQuery ) return ;
123
- const { id, cacheOptions, noFetch } = item .value ?.getProgressQuery () ?? {};
124
- if (! id ) return ;
125
- return getShowWatchedProgress (id , cacheOptions , noFetch ).value ;
126
- });
127
-
128
- const collection = computed <ShowProgress | undefined >(() => {
129
- if (! showCollected .value ) return ;
130
- if (! item ?.value ?.getProgressQuery ) return ;
131
- const { id, noFetch } = item .value ?.getProgressQuery () ?? {};
132
- if (! id ) return ;
133
- return getShowCollectionProgress (id , noFetch ).value ;
134
- });
135
-
136
- const { getMovieWatched, getMovieCollected } = useMovieStore ();
137
- const { getMovieHistory, getEpisodeHistory } = useHistoryStore ();
138
-
139
- const movieHistory = computed (() => {
140
- if (! showPlayed .value ) return ;
141
- const _item = item ?.value ;
142
- if (_item ?.type !== ' movie' ) return ;
143
- if (! _item ?.meta ?.ids ?.movie ?.trakt ) return ;
144
- return getMovieHistory (_item .meta .ids .movie .trakt )?.value ;
145
- });
146
-
147
- const episodeHistory = computed (() => {
148
- if (! showPlayed .value ) return ;
149
- const _item = item ?.value ;
150
- if (_item ?.type !== ' episode' ) return ;
151
- if (! _item ?.meta ?.ids ?.episode ?.trakt ) return ;
152
- return getEpisodeHistory (_item .meta .ids .episode .trakt )?.value ;
153
- });
154
-
155
- const episodeProgress = computed (() => {
156
- if (! showPlayed .value ) return ;
157
- const _item = item ?.value ;
158
- if (_item ?.type !== ' episode' ) return ;
159
- const _progress = progress .value ;
160
- if (! _progress ) return ;
161
- const _season = _item .meta ?.number ?.season ;
162
- const _episode = _item .meta ?.number ?.episode ;
163
- if (! _season || ! _episode ) return ;
164
- return _progress .seasons
165
- ?.find (s => s .number === _season )
166
- ?.episodes ?.find (e => e .number === _episode );
167
- });
168
-
169
- const movieWatched = computed (() => {
170
- if (! showPlayed .value ) return ;
171
- const _item = item ?.value ;
172
- if (_item ?.type !== ' movie' ) return ;
173
- if (! _item ?.meta ?.ids ?.movie ?.trakt ) return ;
174
- return getMovieWatched (_item .meta .ids .movie .trakt )?.value ;
175
- });
176
-
177
- const moviePlayed = computed (() => {
178
- if (! showPlayed .value ) return ;
179
- if (movieWatched .value !== undefined ) return movieWatched .value ?.last_watched_at ;
180
- return movieHistory .value ?.watched_at ;
181
- });
182
-
183
- const episodePlayed = computed (() => {
184
- if (! showPlayed .value ) return ;
185
- if (episodeProgress .value !== undefined ) {
186
- return {
187
- date: episodeProgress .value ?.date ,
188
- completed: episodeProgress .value ?.completed ,
189
- };
190
- }
191
- return {
192
- date: episodeHistory .value ?.watched_at ,
193
- completed: !! episodeHistory .value ,
194
- };
195
- });
196
-
197
- const played = computed (() => {
198
- if (! showPlayed .value ) return false ;
199
- if (item ?.value ?.type === ' movie' ) return !! moviePlayed .value ;
200
- if (item ?.value ?.type !== ' episode' ) return false ;
201
- return episodePlayed .value ?.completed ;
202
- });
203
-
204
- const playedDate = computed (() => {
205
- if (! played .value ) return ;
206
- if (item ?.value ?.type === ' movie' ) {
207
- if (! moviePlayed .value ) return ;
208
- return new Date (moviePlayed .value ).toLocaleString ();
209
- }
210
- if (! episodePlayed .value ?.date ) return ;
211
- return new Date (episodePlayed .value ?.date ).toLocaleString ();
212
- });
213
-
214
- const collected = computed (() => {
215
- if (! showCollected .value ) return false ;
216
- const _item = item ?.value ;
217
- if (_item ?.type === ' movie' && _item ?.meta ?.ids ?.movie ?.trakt ) {
218
- return getMovieCollected (_item .meta .ids .movie .trakt )?.value ?.collected_at ;
219
- }
220
- if (_item ?.type !== ' episode' ) return false ;
221
- const _collection = collection .value ;
222
-
223
- if (! _collection ) return false ;
224
- const _season = _item .meta ?.number ?.season ;
225
- const _episode = _item .meta ?.number ?.episode ;
226
- if (! _season || ! _episode ) return false ;
227
- return _collection .seasons
228
- ?.find (s => s .number === _season )
229
- ?.episodes ?.find (e => e .number === _episode )?.date ;
230
- });
231
-
232
- const collectedDate = computed (() => {
233
- if (! collected .value ) return ;
234
- if (typeof collected .value !== ' string' ) return ;
235
- return new Date (collected .value ).toLocaleString ();
236
- });
114
+ const {
115
+ progress,
116
+ played,
117
+ date : playedDate,
118
+ } = useItemPlayed (item , { showPlayed , showProgress });
119
+ const { collected, date : collectedDate } = useItemCollected (item , showCollected );
237
120
238
121
const { progressType } = useExtensionSettingsStoreRefs ();
239
122
@@ -461,7 +344,6 @@ const onTagClick = (url?: string) => {
461
344
gap : 0.5rem !important ;
462
345
max-height : 3.325rem ;
463
346
margin-top : 0.3rem ;
464
- overflow : scroll ;
465
347
466
348
& .show-progress {
467
349
max-height : 1.5rem ;
0 commit comments