@@ -4,15 +4,24 @@ import { ref } from 'vue';
4
4
5
5
import type { TraktEpisode , TraktShow } from '@dvcol/trakt-http-client/models' ;
6
6
7
+ import type { ListScrollItem , ListScrollItemMeta , ListScrollSourceItem } from '~/models/list-scroll.model' ;
8
+
7
9
import { getContent , getTags , getTitle } from '~/components/common/list/use-list-scroll' ;
8
- import { type ListScrollItem , type ListScrollSourceItem } from '~/models/list-scroll.model' ;
9
10
import { type ProgressItem } from '~/models/progress.model' ;
10
11
import { Logger } from '~/services/logger.service' ;
11
12
import { NotificationService } from '~/services/notification.service' ;
12
13
import { TraktService } from '~/services/trakt.service' ;
13
14
import { debounceLoading , useLoadingPlaceholder } from '~/utils/store.utils' ;
14
15
15
- type ProgressListItem = Omit < ListScrollItem , 'posterRef' | 'progressRef' > ;
16
+ export type ProgressListItem = Omit <
17
+ ListScrollItem <
18
+ ListScrollItemMeta < {
19
+ episode : ListScrollSourceItem [ 'episode' ] ;
20
+ show : ListScrollSourceItem [ 'show' ] ;
21
+ } >
22
+ > ,
23
+ 'posterRef' | 'progressRef'
24
+ > ;
16
25
17
26
const titleRegex = / ( .* ) \s \d + x \d + \s " ( [ ^ " ] + ) " / ;
18
27
@@ -77,6 +86,11 @@ export const progressToListItem = (progress: ProgressItem, index: number): Progr
77
86
} ;
78
87
} ;
79
88
89
+ export const fetchProgressData = async ( ) : Promise < ProgressListItem [ ] > => {
90
+ const items = await TraktService . progress . onDeck ( ) ;
91
+ return items . map < ProgressListItem > ( progressToListItem ) ;
92
+ } ;
93
+
80
94
export const useProgressStore = defineStore ( 'data.progress' , ( ) => {
81
95
const firstLoad = ref ( true ) ;
82
96
const loading = ref ( true ) ;
@@ -100,8 +114,7 @@ export const useProgressStore = defineStore('data.progress', () => {
100
114
loading . value = true ;
101
115
const timeout = debounceLoading ( progress , loadingPlaceholder , true ) ;
102
116
try {
103
- const items = await TraktService . progress . onDeck ( ) ;
104
- progress . value = items . map < ProgressListItem > ( progressToListItem ) ;
117
+ progress . value = await fetchProgressData ( ) ;
105
118
} catch ( error ) {
106
119
progress . value = [ ] ;
107
120
loading . value = false ;
0 commit comments