Fixed: Calendar Items Show on Correct Day

pull/2/head
Qstick 5 years ago
parent 582402d45e
commit 6288936fe2

@ -13,14 +13,14 @@ function Agenda(props) {
<div className={styles.agenda}> <div className={styles.agenda}>
{ {
items.map((item, index) => { items.map((item, index) => {
const momentDate = moment(item.airDateUtc); const momentDate = moment(item.inCinemas);
const showDate = index === 0 || const showDate = index === 0 ||
!moment(items[index - 1].airDateUtc).isSame(momentDate, 'day'); !moment(items[index - 1].inCinemas).isSame(momentDate, 'day');
return ( return (
<AgendaEventConnector <AgendaEventConnector
key={item.id} key={item.id}
episodeId={item.id} movieId={item.id}
showDate={showDate} showDate={showDate}
{...item} {...item}
/> />

@ -30,8 +30,7 @@
border: none !important; border: none !important;
} }
.seriesTitle, .movieTitle {
.episodeTitle {
@add-mixin truncate; @add-mixin truncate;
flex: 0 1 300px; flex: 0 1 300px;

@ -78,7 +78,7 @@ class AgendaEvent extends Component {
colorImpairedMode && 'colorImpaired' colorImpairedMode && 'colorImpaired'
)} )}
> >
<div className={styles.seriesTitle}> <div className={styles.movieTitle}>
<MovieTitleLink <MovieTitleLink
titleSlug={titleSlug} titleSlug={titleSlug}
title={title} title={title}

@ -13,10 +13,10 @@ function createMapStateToProps() {
createMovieFileSelector(), createMovieFileSelector(),
createQueueItemSelector(), createQueueItemSelector(),
createUISettingsSelector(), createUISettingsSelector(),
(calendarOptions, series, episodeFile, queueItem, uiSettings) => { (calendarOptions, movie, movieFile, queueItem, uiSettings) => {
return { return {
series, movie,
episodeFile, movieFile,
queueItem, queueItem,
...calendarOptions, ...calendarOptions,
timeFormat: uiSettings.timeFormat, timeFormat: uiSettings.timeFormat,

@ -76,15 +76,15 @@ class CalendarConnector extends Component {
} = this.props; } = this.props;
if (hasDifferentItems(prevProps.items, items)) { if (hasDifferentItems(prevProps.items, items)) {
const episodeIds = selectUniqueIds(items, 'id'); const movieIds = selectUniqueIds(items, 'id');
const episodeFileIds = selectUniqueIds(items, 'episodeFileId'); const movieFileIds = selectUniqueIds(items, 'movieFileId');
if (items.length) { if (items.length) {
this.props.fetchQueueDetails({ episodeIds }); this.props.fetchQueueDetails({ movieIds });
} }
if (episodeFileIds.length) { if (movieFileIds.length) {
this.props.fetchMovieFiles({ episodeFileIds }); this.props.fetchMovieFiles({ movieFileIds });
} }
} }

@ -60,11 +60,11 @@ class CalendarPage extends Component {
onSearchMissingPress = () => { onSearchMissingPress = () => {
const { const {
missingEpisodeIds, missingMovieIds,
onSearchMissingPress onSearchMissingPress
} = this.props; } = this.props;
onSearchMissingPress(missingEpisodeIds); onSearchMissingPress(missingMovieIds);
} }
// //
@ -75,7 +75,7 @@ class CalendarPage extends Component {
selectedFilterKey, selectedFilterKey,
filters, filters,
hasMovie, hasMovie,
missingEpisodeIds, missingMovieIds,
isSearchingForMissing, isSearchingForMissing,
useCurrentPage, useCurrentPage,
onFilterSelect onFilterSelect
@ -102,7 +102,7 @@ class CalendarPage extends Component {
<PageToolbarButton <PageToolbarButton
label="Search for Missing" label="Search for Missing"
iconName={icons.SEARCH} iconName={icons.SEARCH}
isDisabled={!missingEpisodeIds.length} isDisabled={!missingMovieIds.length}
isSpinning={isSearchingForMissing} isSpinning={isSearchingForMissing}
onPress={this.onSearchMissingPress} onPress={this.onSearchMissingPress}
/> />
@ -167,7 +167,7 @@ CalendarPage.propTypes = {
selectedFilterKey: PropTypes.string.isRequired, selectedFilterKey: PropTypes.string.isRequired,
filters: PropTypes.arrayOf(PropTypes.object).isRequired, filters: PropTypes.arrayOf(PropTypes.object).isRequired,
hasMovie: PropTypes.bool.isRequired, hasMovie: PropTypes.bool.isRequired,
missingEpisodeIds: PropTypes.arrayOf(PropTypes.number).isRequired, missingMovieIds: PropTypes.arrayOf(PropTypes.number).isRequired,
isSearchingForMissing: PropTypes.bool.isRequired, isSearchingForMissing: PropTypes.bool.isRequired,
useCurrentPage: PropTypes.bool.isRequired, useCurrentPage: PropTypes.bool.isRequired,
onSearchMissingPress: PropTypes.func.isRequired, onSearchMissingPress: PropTypes.func.isRequired,

@ -10,24 +10,24 @@ import createUISettingsSelector from 'Store/Selectors/createUISettingsSelector';
import createCommandsSelector from 'Store/Selectors/createCommandsSelector'; import createCommandsSelector from 'Store/Selectors/createCommandsSelector';
import CalendarPage from './CalendarPage'; import CalendarPage from './CalendarPage';
function createMissingEpisodeIdsSelector() { function createMissingMovieIdsSelector() {
return createSelector( return createSelector(
(state) => state.calendar.start, (state) => state.calendar.start,
(state) => state.calendar.end, (state) => state.calendar.end,
(state) => state.calendar.items, (state) => state.calendar.items,
(state) => state.queue.details.items, (state) => state.queue.details.items,
(start, end, episodes, queueDetails) => { (start, end, movies, queueDetails) => {
return episodes.reduce((acc, episode) => { return movies.reduce((acc, movie) => {
const airDateUtc = episode.airDateUtc; const inCinemas = movie.inCinemas;
if ( if (
!episode.episodeFileId && !movie.movieFileId &&
moment(airDateUtc).isAfter(start) && moment(inCinemas).isAfter(start) &&
moment(airDateUtc).isBefore(end) && moment(inCinemas).isBefore(end) &&
isBefore(episode.airDateUtc) && isBefore(movie.inCinemas) &&
!queueDetails.some((details) => !!details.episode && details.episode.id === episode.id) !queueDetails.some((details) => !!details.movie && details.movie.id === movie.id)
) { ) {
acc.push(episode.id); acc.push(movie.id);
} }
return acc; return acc;
@ -58,14 +58,14 @@ function createMapStateToProps() {
(state) => state.calendar.filters, (state) => state.calendar.filters,
createMovieCountSelector(), createMovieCountSelector(),
createUISettingsSelector(), createUISettingsSelector(),
createMissingEpisodeIdsSelector(), createMissingMovieIdsSelector(),
createIsSearchingSelector(), createIsSearchingSelector(),
( (
selectedFilterKey, selectedFilterKey,
filters, filters,
movieCount, movieCount,
uiSettings, uiSettings,
missingEpisodeIds, missingMovieIds,
isSearchingForMissing isSearchingForMissing
) => { ) => {
return { return {
@ -73,7 +73,7 @@ function createMapStateToProps() {
filters, filters,
colorImpairedMode: uiSettings.enableColorImpairedMode, colorImpairedMode: uiSettings.enableColorImpairedMode,
hasMovie: !!movieCount, hasMovie: !!movieCount,
missingEpisodeIds, missingMovieIds,
isSearchingForMissing isSearchingForMissing
}; };
} }
@ -82,8 +82,8 @@ function createMapStateToProps() {
function createMapDispatchToProps(dispatch, props) { function createMapDispatchToProps(dispatch, props) {
return { return {
onSearchMissingPress(episodeIds) { onSearchMissingPress(movieIds) {
dispatch(searchMissing({ episodeIds })); dispatch(searchMissing({ movieIds }));
}, },
onDaysCountChange(dayCount) { onDaysCountChange(dayCount) {

@ -4,7 +4,6 @@ import React from 'react';
import classNames from 'classnames'; import classNames from 'classnames';
import * as calendarViews from 'Calendar/calendarViews'; import * as calendarViews from 'Calendar/calendarViews';
import CalendarEventConnector from 'Calendar/Events/CalendarEventConnector'; import CalendarEventConnector from 'Calendar/Events/CalendarEventConnector';
import CalendarEventGroupConnector from 'Calendar/Events/CalendarEventGroupConnector';
import styles from './CalendarDay.css'; import styles from './CalendarDay.css';
function CalendarDay(props) { function CalendarDay(props) {
@ -37,20 +36,10 @@ function CalendarDay(props) {
<div> <div>
{ {
events.map((event) => { events.map((event) => {
if (event.isGroup) {
return (
<CalendarEventGroupConnector
key={event.seriesId}
{...event}
onEventModalOpenToggle={onEventModalOpenToggle}
/>
);
}
return ( return (
<CalendarEventConnector <CalendarEventConnector
key={event.id} key={event.id}
episodeId={event.id} movieId={event.id}
{...event} {...event}
onEventModalOpenToggle={onEventModalOpenToggle} onEventModalOpenToggle={onEventModalOpenToggle}
/> />

@ -9,10 +9,10 @@ import CalendarDay from './CalendarDay';
function sort(items) { function sort(items) {
return _.sortBy(items, (item) => { return _.sortBy(items, (item) => {
if (item.isGroup) { 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,39 +20,13 @@ function createCalendarEventsConnector() {
return createSelector( return createSelector(
(state, { date }) => date, (state, { date }) => date,
(state) => state.calendar.items, (state) => state.calendar.items,
(state) => state.calendar.options.collapseMultipleEpisodes, (date, items) => {
(date, items, collapseMultipleEpisodes) => {
const filtered = _.filter(items, (item) => { 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); 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;
}
); );
} }

@ -52,13 +52,13 @@ function Legend(props) {
<div> <div>
<LegendItem <LegendItem
status="unaired" status="unaired"
tooltip="Episode hasn't aired yet" tooltip="Movie hasn't aired yet"
colorImpairedMode={colorImpairedMode} colorImpairedMode={colorImpairedMode}
/> />
<LegendItem <LegendItem
status="unmonitored" status="unmonitored"
tooltip="Episode is unmonitored" tooltip="Movie is unmonitored"
colorImpairedMode={colorImpairedMode} colorImpairedMode={colorImpairedMode}
/> />
</div> </div>
@ -66,13 +66,13 @@ function Legend(props) {
<div> <div>
<LegendItem <LegendItem
status="downloading" status="downloading"
tooltip="Episode is currently downloading" tooltip="Movie is currently downloading"
colorImpairedMode={colorImpairedMode} colorImpairedMode={colorImpairedMode}
/> />
<LegendItem <LegendItem
status="downloaded" status="downloaded"
tooltip="Episode was downloaded and sorted" tooltip="Movie was downloaded and sorted"
colorImpairedMode={colorImpairedMode} colorImpairedMode={colorImpairedMode}
/> />
</div> </div>

Loading…
Cancel
Save