From 6288936fe231706e4ba1b3d4eefb1c94fee8e67f Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 27 Jul 2019 00:56:07 -0400 Subject: [PATCH] Fixed: Calendar Items Show on Correct Day --- frontend/src/Calendar/Agenda/Agenda.js | 6 ++-- frontend/src/Calendar/Agenda/AgendaEvent.css | 3 +- frontend/src/Calendar/Agenda/AgendaEvent.js | 2 +- .../Calendar/Agenda/AgendaEventConnector.js | 6 ++-- frontend/src/Calendar/CalendarConnector.js | 10 +++--- frontend/src/Calendar/CalendarPage.js | 10 +++--- .../src/Calendar/CalendarPageConnector.js | 30 ++++++++-------- frontend/src/Calendar/Day/CalendarDay.js | 13 +------ .../src/Calendar/Day/CalendarDayConnector.js | 36 +++---------------- frontend/src/Calendar/Legend/Legend.js | 8 ++--- 10 files changed, 43 insertions(+), 81 deletions(-) diff --git a/frontend/src/Calendar/Agenda/Agenda.js b/frontend/src/Calendar/Agenda/Agenda.js index 89472301d..babc5b83f 100644 --- a/frontend/src/Calendar/Agenda/Agenda.js +++ b/frontend/src/Calendar/Agenda/Agenda.js @@ -13,14 +13,14 @@ function Agenda(props) {
{ items.map((item, index) => { - const momentDate = moment(item.airDateUtc); + const momentDate = moment(item.inCinemas); const showDate = index === 0 || - !moment(items[index - 1].airDateUtc).isSame(momentDate, 'day'); + !moment(items[index - 1].inCinemas).isSame(momentDate, 'day'); return ( diff --git a/frontend/src/Calendar/Agenda/AgendaEvent.css b/frontend/src/Calendar/Agenda/AgendaEvent.css index 7a026e622..996de36d4 100644 --- a/frontend/src/Calendar/Agenda/AgendaEvent.css +++ b/frontend/src/Calendar/Agenda/AgendaEvent.css @@ -30,8 +30,7 @@ border: none !important; } -.seriesTitle, -.episodeTitle { +.movieTitle { @add-mixin truncate; flex: 0 1 300px; diff --git a/frontend/src/Calendar/Agenda/AgendaEvent.js b/frontend/src/Calendar/Agenda/AgendaEvent.js index dc5d51eae..8662b8a55 100644 --- a/frontend/src/Calendar/Agenda/AgendaEvent.js +++ b/frontend/src/Calendar/Agenda/AgendaEvent.js @@ -78,7 +78,7 @@ class AgendaEvent extends Component { colorImpairedMode && 'colorImpaired' )} > -
+
{ + (calendarOptions, movie, movieFile, queueItem, uiSettings) => { return { - series, - episodeFile, + movie, + movieFile, queueItem, ...calendarOptions, timeFormat: uiSettings.timeFormat, diff --git a/frontend/src/Calendar/CalendarConnector.js b/frontend/src/Calendar/CalendarConnector.js index e6b097c35..ce121c593 100644 --- a/frontend/src/Calendar/CalendarConnector.js +++ b/frontend/src/Calendar/CalendarConnector.js @@ -76,15 +76,15 @@ class CalendarConnector extends Component { } = this.props; if (hasDifferentItems(prevProps.items, items)) { - const episodeIds = selectUniqueIds(items, 'id'); - const episodeFileIds = selectUniqueIds(items, 'episodeFileId'); + const movieIds = selectUniqueIds(items, 'id'); + const movieFileIds = selectUniqueIds(items, 'movieFileId'); if (items.length) { - this.props.fetchQueueDetails({ episodeIds }); + this.props.fetchQueueDetails({ movieIds }); } - if (episodeFileIds.length) { - this.props.fetchMovieFiles({ episodeFileIds }); + if (movieFileIds.length) { + this.props.fetchMovieFiles({ movieFileIds }); } } diff --git a/frontend/src/Calendar/CalendarPage.js b/frontend/src/Calendar/CalendarPage.js index a6ea88245..3f93fcad8 100644 --- a/frontend/src/Calendar/CalendarPage.js +++ b/frontend/src/Calendar/CalendarPage.js @@ -60,11 +60,11 @@ class CalendarPage extends Component { onSearchMissingPress = () => { const { - missingEpisodeIds, + missingMovieIds, onSearchMissingPress } = this.props; - onSearchMissingPress(missingEpisodeIds); + onSearchMissingPress(missingMovieIds); } // @@ -75,7 +75,7 @@ class CalendarPage extends Component { selectedFilterKey, filters, hasMovie, - missingEpisodeIds, + missingMovieIds, isSearchingForMissing, useCurrentPage, onFilterSelect @@ -102,7 +102,7 @@ class CalendarPage extends Component { @@ -167,7 +167,7 @@ CalendarPage.propTypes = { selectedFilterKey: PropTypes.string.isRequired, filters: PropTypes.arrayOf(PropTypes.object).isRequired, hasMovie: PropTypes.bool.isRequired, - missingEpisodeIds: PropTypes.arrayOf(PropTypes.number).isRequired, + missingMovieIds: PropTypes.arrayOf(PropTypes.number).isRequired, isSearchingForMissing: PropTypes.bool.isRequired, useCurrentPage: PropTypes.bool.isRequired, onSearchMissingPress: PropTypes.func.isRequired, diff --git a/frontend/src/Calendar/CalendarPageConnector.js b/frontend/src/Calendar/CalendarPageConnector.js index 1b812a556..e131f85af 100644 --- a/frontend/src/Calendar/CalendarPageConnector.js +++ b/frontend/src/Calendar/CalendarPageConnector.js @@ -10,24 +10,24 @@ import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector'; import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import CalendarPage from './CalendarPage'; -function createMissingEpisodeIdsSelector() { +function createMissingMovieIdsSelector() { return createSelector( (state) => state.calendar.start, (state) => state.calendar.end, (state) => state.calendar.items, (state) => state.queue.details.items, - (start, end, episodes, queueDetails) => { - return episodes.reduce((acc, episode) => { - const airDateUtc = episode.airDateUtc; + (start, end, movies, queueDetails) => { + return movies.reduce((acc, movie) => { + const inCinemas = movie.inCinemas; if ( - !episode.episodeFileId && - moment(airDateUtc).isAfter(start) && - moment(airDateUtc).isBefore(end) && - isBefore(episode.airDateUtc) && - !queueDetails.some((details) => !!details.episode && details.episode.id === episode.id) + !movie.movieFileId && + moment(inCinemas).isAfter(start) && + moment(inCinemas).isBefore(end) && + isBefore(movie.inCinemas) && + !queueDetails.some((details) => !!details.movie && details.movie.id === movie.id) ) { - acc.push(episode.id); + acc.push(movie.id); } return acc; @@ -58,14 +58,14 @@ function createMapStateToProps() { (state) => state.calendar.filters, createMovieCountSelector(), createUISettingsSelector(), - createMissingEpisodeIdsSelector(), + createMissingMovieIdsSelector(), createIsSearchingSelector(), ( selectedFilterKey, filters, movieCount, uiSettings, - missingEpisodeIds, + missingMovieIds, isSearchingForMissing ) => { return { @@ -73,7 +73,7 @@ function createMapStateToProps() { filters, colorImpairedMode: uiSettings.enableColorImpairedMode, hasMovie: !!movieCount, - missingEpisodeIds, + missingMovieIds, isSearchingForMissing }; } @@ -82,8 +82,8 @@ function createMapStateToProps() { function createMapDispatchToProps(dispatch, props) { return { - onSearchMissingPress(episodeIds) { - dispatch(searchMissing({ episodeIds })); + onSearchMissingPress(movieIds) { + dispatch(searchMissing({ movieIds })); }, onDaysCountChange(dayCount) { diff --git a/frontend/src/Calendar/Day/CalendarDay.js b/frontend/src/Calendar/Day/CalendarDay.js index faa45b28b..91f473779 100644 --- a/frontend/src/Calendar/Day/CalendarDay.js +++ b/frontend/src/Calendar/Day/CalendarDay.js @@ -4,7 +4,6 @@ import React from 'react'; import classNames from 'classnames'; import * as calendarViews from 'Calendar/calendarViews'; import CalendarEventConnector from 'Calendar/Events/CalendarEventConnector'; -import CalendarEventGroupConnector from 'Calendar/Events/CalendarEventGroupConnector'; import styles from './CalendarDay.css'; function CalendarDay(props) { @@ -37,20 +36,10 @@ function CalendarDay(props) {
{ events.map((event) => { - if (event.isGroup) { - return ( - - ); - } - return ( diff --git a/frontend/src/Calendar/Day/CalendarDayConnector.js b/frontend/src/Calendar/Day/CalendarDayConnector.js index 8fd6cc5a1..01838f644 100644 --- a/frontend/src/Calendar/Day/CalendarDayConnector.js +++ b/frontend/src/Calendar/Day/CalendarDayConnector.js @@ -9,10 +9,10 @@ import CalendarDay from './CalendarDay'; function sort(items) { return _.sortBy(items, (item) => { if (item.isGroup) { - return moment(item.events[0].airDateUtc).unix(); + return moment(item.events[0].inCinemas).unix(); } - return moment(item.airDateUtc).unix(); + return moment(item.inCinemas).unix(); }); } @@ -20,38 +20,12 @@ function createCalendarEventsConnector() { return createSelector( (state, { date }) => date, (state) => state.calendar.items, - (state) => state.calendar.options.collapseMultipleEpisodes, - (date, items, collapseMultipleEpisodes) => { + (date, items) => { const filtered = _.filter(items, (item) => { - return moment(date).isSame(moment(item.airDateUtc), 'day'); + return moment(date).isSame(moment(item.inCinemas), 'day'); }); - if (!collapseMultipleEpisodes) { - return sort(filtered); - } - - const groupedObject = _.groupBy(filtered, (item) => `${item.seriesId}-${item.seasonNumber}`); - const grouped = []; - - Object.keys(groupedObject).forEach((key) => { - const events = groupedObject[key]; - - if (events.length === 1) { - grouped.push(events[0]); - } else { - grouped.push({ - isGroup: true, - seriesId: events[0].seriesId, - seasonNumber: events[0].seasonNumber, - episodeIds: events.map((event) => event.id), - events: _.sortBy(events, (item) => moment(item.airDateUtc).unix()) - }); - } - }); - - const sorted = sort(grouped); - - return sorted; + return sort(filtered); } ); } diff --git a/frontend/src/Calendar/Legend/Legend.js b/frontend/src/Calendar/Legend/Legend.js index 9bc6303f3..10293ff1b 100644 --- a/frontend/src/Calendar/Legend/Legend.js +++ b/frontend/src/Calendar/Legend/Legend.js @@ -52,13 +52,13 @@ function Legend(props) {
@@ -66,13 +66,13 @@ function Legend(props) {