Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): display season count on TV details page #1078

Merged
merged 2 commits into from
Mar 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/components/TvDetails/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const messages = defineMessages({
markavailable: 'Mark as Available',
mark4kavailable: 'Mark 4K as Available',
allseasonsmarkedavailable: '* All seasons will be marked as available.',
seasons: '{seasonCount} Seasons',
});

interface TvDetailsProps {
Expand Down Expand Up @@ -178,20 +179,29 @@ const TvDetails: React.FC<TvDetailsProps> = ({ tv }) => {
);
}

const seasonCount = data.seasons.filter((season) => season.seasonNumber !== 0)
.length;

if (seasonCount) {
seriesAttributes.push(
intl.formatMessage(messages.seasons, { seasonCount: seasonCount })
);
}

if (data.genres.length) {
seriesAttributes.push(data.genres.map((g) => g.name).join(', '));
}

const isComplete =
data.seasons.filter((season) => season.seasonNumber !== 0).length <=
seasonCount <=
(
data.mediaInfo?.seasons.filter(
(season) => season.status === MediaStatus.AVAILABLE
) ?? []
).length;

const is4kComplete =
data.seasons.filter((season) => season.seasonNumber !== 0).length <=
seasonCount <=
(
data.mediaInfo?.seasons.filter(
(season) => season.status4k === MediaStatus.AVAILABLE
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,7 @@
"components.TvDetails.playonplex": "Play on Plex",
"components.TvDetails.recommendations": "Recommendations",
"components.TvDetails.recommendationssubtext": "If you liked {title}, you might also like…",
"components.TvDetails.seasons": "{seasonCount} Seasons",
"components.TvDetails.showtype": "Show Type",
"components.TvDetails.similar": "Similar Series",
"components.TvDetails.similarsubtext": "Other series similar to {title}",
Expand Down