Skip to content

Commit

Permalink
fixing ts errors
Browse files Browse the repository at this point in the history
  • Loading branch information
stephiescastle committed Sep 15, 2024
1 parent f2aecd6 commit cfbfb57
Showing 1 changed file with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
:initial-slide="
activeSeasonId === initialSeasonId && initialEpisodeIndex ? initialEpisodeIndex : 0
"
:slides="activeTabData.episodes"
:slides="activeTabData.episodes as Partial<Slide>[]"
/>
</keep-alive>
</div>
Expand All @@ -61,6 +61,12 @@ import ThumbnailCarousel from './../ThumbnailCarousel/ThumbnailCarousel.vue'
const route = useRoute()
interface Slide {
url: string
title: string
thumbnailImage: Partial<ImageObject>
}
interface Episode {
url: string
title: string
Expand All @@ -74,15 +80,15 @@ interface ActiveTab {
}
interface Season {
id?: string
id: string
url?: string
title?: string
seasonNumber?: number
episodes?: Episode[]
}
interface Series {
id?: string
id: string
title?: string
url?: string
seasons?: Season[]
Expand Down Expand Up @@ -112,11 +118,16 @@ export default defineComponent({
}
},
computed: {
sortedSeasons(): Season[] | null {
sortedSeasons(): Season[] | undefined {
let seasons = undefined
if (this.series && this.series.seasons) {
seasons = this.series.seasons
seasons = seasons.toSorted((a: Season, b: Season) => a.seasonNumber - b.seasonNumber)
// @ts-expect-error seasons is an array
seasons = seasons.toSorted((a: Season, b: Season) => {
if (a.seasonNumber && b.seasonNumber) {
return a.seasonNumber - b.seasonNumber
}
})
return seasons
}
return seasons
Expand Down Expand Up @@ -156,10 +167,12 @@ export default defineComponent({
}
if (season?.episodes?.length) {
let episodes: Episode[] = season.episodes
episodes = episodes.toSorted(
(a: Episode, b: Episode) =>
new Date(a.publicationDate).getTime() - new Date(b.publicationDate).getTime()
)
// @ts-expect-error episodes is an array
episodes = episodes.toSorted((a: Episode, b: Episode) => {
if (a.publicationDate && b.publicationDate) {
return new Date(a.publicationDate).getTime() - new Date(b.publicationDate).getTime()
}
})
season = {
...season,
episodes: episodes
Expand Down

0 comments on commit cfbfb57

Please sign in to comment.