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

Added useful groups to "My" screen #35

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion src/localization/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,13 @@ export default {
'new-season-day': 'Season in a day',
'new-season-custom-date': ({ date }) => `Season ${date}`,

'my-caption': 'My',
'my-caption': 'My TV Shows',

'my-all': 'All',
'my-closed': 'Closed',
'my-watched': 'Watched',
'my-new-episodes': 'New episodes',
'my-new-episodes-soon': 'New episodes soon',

'my-empty-list-title': 'You don\'t have any subscriptions',
'my-empty-list-description': 'You can start from adding some tv series from "TV Shows" sections',
Expand Down
6 changes: 4 additions & 2 deletions src/localization/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,13 @@ export default {
'new-season-day': 'Сезон в течение дня',
'new-season-custom-date': ({ date }) => `Сезон ${date}`,

'my-caption': 'Мои',
'my-caption': 'Мои сериалы',

'my-all': 'Все',
'my-closed': 'Завершенные',
'my-watched': 'Просмотренные',
'my-new-episodes': 'С новыми эпизодами',
'my-new-episodes': 'Новые эпизоды',
'my-new-episodes-soon': 'Скоро выходят',

'my-empty-list-title': 'У тебя нет никаких подписок',
'my-empty-list-description': 'Ты можешь начать с добавления каких-нибудь сериалов из раздела "Сериалы"',
Expand Down
78 changes: 57 additions & 21 deletions src/routes/my.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,31 +144,74 @@ export default function myRoute() {
return item.status > 0 && !item.unwatched;
});

const newEpisodesSoon = schedule
.map(({ sid }) => sid)
.filter((sid, i, list) => list.indexOf(sid) === i)
.map(sid => series.find(serie => serie.sid === sid))
.filter(Boolean);

const sections = [
{
title: i18n('my-new-episodes'),
count: unwatched.length,
content: this.renderSectionGrid(unwatched),
},
{
title: i18n('my-new-episodes-soon'),
count: newEpisodesSoon.length,
content: this.renderSectionGrid(newEpisodesSoon, schedule),
},
{
title: i18n('my-watched'),
count: watched.length,
content: this.renderSectionGrid(watched, schedule),
},
{
title: i18n('my-closed'),
count: closed.length,
content: this.renderSectionGrid(closed),
},
{
title: i18n('my-all'),
count: series.length,
content: this.renderSectionGrid(series, schedule),
},
];

return (
<document>
<stackTemplate>
<catalogTemplate>
<banner>
<title>
{i18n('my-caption')}
</title>
</banner>
<collectionList>
{unwatched.length && (
this.renderSectionGrid(unwatched, 'my-new-episodes')
)}
{watched.length && (
this.renderSectionGrid(watched, 'my-watched', schedule)
)}
{closed.length && (
this.renderSectionGrid(closed, 'my-closed')
)}
</collectionList>
</stackTemplate>
<list>
<section>
{sections
.filter(({ count }) => count)
.map(({ title, count, content }) => (
<listItemLockup key={title}>
<title>
{title}
</title>
<decorationLabel>
{count}
</decorationLabel>
<relatedContent>
{content}
</relatedContent>
</listItemLockup>
))
}
</section>
</list>
</catalogTemplate>
</document>
);
},

renderSectionGrid(collection, title, schedule = []) {
renderSectionGrid(collection, schedule = []) {
const scheduleDictionary = schedule.reduce((result, item) => {
// eslint-disable-next-line no-param-reassign
result[item.sid] = item;
Expand All @@ -187,13 +230,6 @@ export default function myRoute() {

return (
<grid>
{title && (
<header>
<title>
{i18n(title)}
</title>
</header>
)}
<section>
{collection.map(tvshow => {
const {
Expand Down