@@ -7,6 +7,7 @@ import type { TraktClientPagination } from '~/models/trakt/trakt-client.model';
7
7
import type { ImageQuery } from '~/stores/data/image.store' ;
8
8
9
9
import { type ListScrollItem , ListScrollItemType , type ListScrollSourceItem , type OnScroll , type OnUpdated } from '~/models/list-scroll.model' ;
10
+ import { useI18n } from '~/utils' ;
10
11
11
12
export type ListScrollSourceItemWithDate < T extends string > = ListScrollSourceItem & Partial < Record < T , string | number | Date > > ;
12
13
@@ -15,8 +16,7 @@ export const getTitle = (media: Pick<ListScrollSourceItem, 'person' | 'movie' |
15
16
if ( media . person ) return media . person . name ;
16
17
if ( media . movie ) return media . movie . title ;
17
18
if ( ! media . episode ) return media . show ?. title ;
18
- const number = media . episode . number ?. toString ( ) . padStart ( 2 , '0' ) ;
19
- return `${ media . episode . season } x${ number } - ${ media . episode . title } ` ;
19
+ return media . episode . title ;
20
20
} ;
21
21
22
22
export const getContent = ( media : Pick < ListScrollSourceItem , 'movie' | 'episode' | 'show' > ) : ListScrollItem [ 'content' ] => {
@@ -79,6 +79,38 @@ export const getPosterQuery =
79
79
} satisfies ImageQuery ;
80
80
} ;
81
81
82
+ const i18n = useI18n ( 'common' , 'tag' ) ;
83
+ export const getTags = ( item : Pick < ListScrollSourceItem , 'episode' | 'season' > , type : ListScrollItem [ 'type' ] ) : ListScrollItem [ 'tags' ] => {
84
+ const tags : ListScrollItem [ 'tags' ] = [ ] ;
85
+ if ( type === 'episode' && item . episode ) {
86
+ let premiere : 'season' | 'series' | 'mid_season' | null = null ;
87
+ // let finale: 'season' | 'series' | 'mid_season';
88
+ if ( item . episode . season === 1 && item . episode . number === 1 ) premiere = 'series' ;
89
+ else if ( item . episode . number === 1 ) premiere = 'season' ;
90
+
91
+ if ( premiere ) {
92
+ tags . push ( {
93
+ label : premiere ,
94
+ i18n : [ 'calendar' , 'tag' , 'label' , 'premiere' ] ,
95
+ type : premiere === 'season' ? 'info' : 'primary' ,
96
+ } ) ;
97
+ }
98
+ tags . push ( {
99
+ label : `${ i18n ( 'season' ) } ${ item . episode . season . toString ( ) . padStart ( 2 , '0' ) } ${ i18n ( 'episode' ) } ${ item . episode . number
100
+ . toString ( )
101
+ . padStart ( 2 , '0' ) } `,
102
+ type : 'warning' ,
103
+ } ) ;
104
+ } else if ( type === 'season' && item . season ) {
105
+ tags . push ( {
106
+ label : `Season ${ item . season . number . toString ( ) . padStart ( 2 , '0' ) } ` ,
107
+ type : 'warning' ,
108
+ } ) ;
109
+ }
110
+
111
+ return tags ;
112
+ } ;
113
+
82
114
export const useListScroll = < T extends ListScrollSourceItemWithDate < D > , D extends string | never = never > (
83
115
items : Ref < T [ ] > ,
84
116
dateFn ?: D | ( ( item : T ) => T [ D ] ) ,
@@ -94,8 +126,11 @@ export const useListScroll = <T extends ListScrollSourceItemWithDate<D>, D exten
94
126
if ( ! _item . content ) _item . content = getContent ( item ) ;
95
127
if ( ! _item . posterRef ) _item . posterRef = ref < string | undefined > ( undefined ) ;
96
128
if ( ! _item . getPosterQuery ) _item . getPosterQuery = getPosterQuery ( item , _item . type ) ;
129
+ if ( ! _item . tags ) _item . tags = getTags ( item , _item . type ) ;
130
+
97
131
_item . date = getDate ( item , array , index , dateFn ) ;
98
132
_item . meta = {
133
+ source : item ,
99
134
ids : {
100
135
movie : item . movie ?. ids ,
101
136
show : item . show ?. ids ,
0 commit comments