|
| 1 | +import type { TraktCollection, TraktFavoriteItem, TraktListItem, TraktUser, TraktWatchlist } from '@dvcol/trakt-http-client/models'; |
| 2 | + |
| 3 | +import type { ListScrollItemType } from '~/models/list-scroll.model'; |
| 4 | + |
| 5 | +export type AnyList = |
| 6 | + | TraktListItem |
| 7 | + | TraktWatchlist |
| 8 | + | TraktFavoriteItem |
| 9 | + | (TraktCollection & { id: number | string; type?: typeof ListScrollItemType.Loading }); |
| 10 | + |
| 11 | +export const ListType = { |
| 12 | + List: 'list', |
| 13 | + Collaboration: 'collaboration', |
| 14 | + Collection: 'collection', |
| 15 | + Watchlist: 'watchlist', |
| 16 | + Favorites: 'favorites', |
| 17 | + History: 'history', |
| 18 | +} as const; |
| 19 | + |
| 20 | +export type ListTypes = (typeof ListType)[keyof typeof ListType]; |
| 21 | + |
| 22 | +export type ListEntity = { |
| 23 | + type: ListTypes; |
| 24 | + id: number | string | DefaultListIds; |
| 25 | + name: string; |
| 26 | + owner?: TraktUser; |
| 27 | + scope?: 'movies' | 'shows'; |
| 28 | +}; |
| 29 | + |
| 30 | +export type AnyListDateTypes = 'listed_at' | 'last_collected_at' | 'collected_at'; |
| 31 | + |
| 32 | +export const DefaultListId = { |
| 33 | + Watchlist: 'watchlist', |
| 34 | + Favorites: 'favorites', |
| 35 | + MovieCollection: 'movie-collection', |
| 36 | + ShowCollection: 'show-collection', |
| 37 | + History: 'history', |
| 38 | +} as const; |
| 39 | + |
| 40 | +export type DefaultListIds = (typeof DefaultListId)[keyof typeof DefaultListId]; |
| 41 | + |
| 42 | +export const DefaultLists = { |
| 43 | + Watchlist: { type: ListType.Watchlist, id: DefaultListId.Watchlist, name: 'list_type__watchlist' }, |
| 44 | + Favorites: { type: ListType.Favorites, id: DefaultListId.Favorites, name: 'list_type__favorites' }, |
| 45 | + MovieCollection: { type: ListType.Collection, id: DefaultListId.MovieCollection, scope: 'movies', name: 'list_type__collection_movie' }, |
| 46 | + ShowCollection: { type: ListType.Collection, id: DefaultListId.ShowCollection, scope: 'shows', name: 'list_type__collection_show' }, |
| 47 | +} as const satisfies Record<string, ListEntity>; |
| 48 | + |
| 49 | +export const DefaultListsTypes: ListTypes[] = Object.values(DefaultLists).map(l => l.type); |
| 50 | + |
| 51 | +export const isDefaultList = (list: ListEntity | ListTypes) => DefaultListsTypes.includes(typeof list === 'string' ? list : list.type); |
0 commit comments