From 1dbb664ef6ddca74f5df9b31a9a5a6cfddbce01c Mon Sep 17 00:00:00 2001 From: Qstick Date: Sat, 11 Jul 2020 00:35:02 -0400 Subject: [PATCH] New: Digital Releases on Calendar, Misc Other Calendar Fixes Fixes #4582 --- frontend/src/Calendar/Agenda/AgendaEvent.js | 6 ++-- .../src/Calendar/Day/CalendarDayConnector.js | 4 ++- frontend/src/Calendar/Events/CalendarEvent.js | 32 ++++++++++++++++--- frontend/src/Calendar/getStatusStyle.js | 7 ++-- src/NzbDrone.Core/Movies/MovieRepository.cs | 3 +- 5 files changed, 38 insertions(+), 14 deletions(-) diff --git a/frontend/src/Calendar/Agenda/AgendaEvent.js b/frontend/src/Calendar/Agenda/AgendaEvent.js index 8662b8a55..ce6cf9298 100644 --- a/frontend/src/Calendar/Agenda/AgendaEvent.js +++ b/frontend/src/Calendar/Agenda/AgendaEvent.js @@ -41,6 +41,7 @@ class AgendaEvent extends Component { movieFile, title, titleSlug, + isAvailable, inCinemas, monitored, hasFile, @@ -55,7 +56,7 @@ class AgendaEvent extends Component { const startTime = moment(inCinemas); const downloading = !!(queueItem || grabbed); const isMonitored = monitored; - const statusStyle = getStatusStyle(hasFile, downloading, startTime, isMonitored); + const statusStyle = getStatusStyle(hasFile, downloading, isAvailable, isMonitored); return (
@@ -126,7 +127,8 @@ AgendaEvent.propTypes = { movieFile: PropTypes.object, title: PropTypes.string.isRequired, titleSlug: PropTypes.string.isRequired, - inCinemas: PropTypes.string.isRequired, + isAvailable: PropTypes.bool.isRequired, + inCinemas: PropTypes.string, monitored: PropTypes.bool.isRequired, hasFile: PropTypes.bool.isRequired, grabbed: PropTypes.bool, diff --git a/frontend/src/Calendar/Day/CalendarDayConnector.js b/frontend/src/Calendar/Day/CalendarDayConnector.js index 86a37ac54..33fa1baa4 100644 --- a/frontend/src/Calendar/Day/CalendarDayConnector.js +++ b/frontend/src/Calendar/Day/CalendarDayConnector.js @@ -22,7 +22,9 @@ function createCalendarEventsConnector() { (state) => state.calendar.items, (date, items) => { const filtered = _.filter(items, (item) => { - return moment(date).isSame(moment(item.inCinemas), 'day') || moment(date).isSame(moment(item.physicalRelease), 'day'); + return (item.inCinemas && moment(date).isSame(moment(item.inCinemas), 'day')) || + (item.physicalRelease && moment(date).isSame(moment(item.physicalRelease), 'day')) || + (item.digitalRelease && moment(date).isSame(moment(item.digitalRelease), 'day')); }); return sort(filtered); diff --git a/frontend/src/Calendar/Events/CalendarEvent.js b/frontend/src/Calendar/Events/CalendarEvent.js index 67ea8dd91..b2edf4469 100644 --- a/frontend/src/Calendar/Events/CalendarEvent.js +++ b/frontend/src/Calendar/Events/CalendarEvent.js @@ -17,11 +17,15 @@ class CalendarEvent extends Component { render() { const { movieFile, + isAvailable, inCinemas, + physicalRelease, + digitalRelease, title, titleSlug, genres, monitored, + certification, hasFile, grabbed, queueItem, @@ -31,13 +35,24 @@ class CalendarEvent extends Component { date } = this.props; - const startTime = moment(inCinemas); const isDownloading = !!(queueItem || grabbed); const isMonitored = monitored; - const statusStyle = getStatusStyle(hasFile, isDownloading, startTime, isMonitored); + const statusStyle = getStatusStyle(hasFile, isDownloading, isAvailable, isMonitored); const joinedGenres = genres.slice(0, 2).join(', '); const link = `/movie/${titleSlug}`; - const eventType = moment(date).isSame(moment(inCinemas), 'day') ? 'In Cinemas' : 'Physical Release'; + const eventType = []; + + if (moment(date).isSame(moment(inCinemas), 'day')) { + eventType.push('Cinemas'); + } + + if (moment(date).isSame(moment(physicalRelease), 'day')) { + eventType.push('Physical'); + } + + if (moment(date).isSame(moment(digitalRelease), 'day')) { + eventType.push('Digital'); + } return (
@@ -100,7 +115,10 @@ class CalendarEvent extends Component { showMovieInformation &&
- {eventType} + {eventType.join(', ')} +
+
+ {certification}
} @@ -117,8 +135,12 @@ CalendarEvent.propTypes = { movieFile: PropTypes.object, title: PropTypes.string.isRequired, titleSlug: PropTypes.string.isRequired, - inCinemas: PropTypes.string.isRequired, + isAvailable: PropTypes.bool.isRequired, + inCinemas: PropTypes.string, + physicalRelease: PropTypes.string, + digitalRelease: PropTypes.string, monitored: PropTypes.bool.isRequired, + certification: PropTypes.string, hasFile: PropTypes.bool.isRequired, grabbed: PropTypes.bool, queueItem: PropTypes.object, diff --git a/frontend/src/Calendar/getStatusStyle.js b/frontend/src/Calendar/getStatusStyle.js index 5cf1ec577..043fba273 100644 --- a/frontend/src/Calendar/getStatusStyle.js +++ b/frontend/src/Calendar/getStatusStyle.js @@ -1,8 +1,5 @@ -/* eslint max-params: 0 */ -import moment from 'moment'; -function getStatusStyle(hasFile, downloading, startTime, isMonitored) { - const currentTime = moment(); +function getStatusStyle(hasFile, downloading, isAvailable, isMonitored) { if (hasFile) { return 'downloaded'; @@ -16,7 +13,7 @@ function getStatusStyle(hasFile, downloading, startTime, isMonitored) { return 'unmonitored'; } - if (startTime.isBefore(currentTime) && !hasFile) { + if (isAvailable && !hasFile) { return 'missing'; } diff --git a/src/NzbDrone.Core/Movies/MovieRepository.cs b/src/NzbDrone.Core/Movies/MovieRepository.cs index b53a9458d..1887cbe0b 100644 --- a/src/NzbDrone.Core/Movies/MovieRepository.cs +++ b/src/NzbDrone.Core/Movies/MovieRepository.cs @@ -147,7 +147,8 @@ namespace NzbDrone.Core.Movies var builder = Builder() .Where(m => (m.InCinemas >= start && m.InCinemas <= end) || - (m.PhysicalRelease >= start && m.PhysicalRelease <= end)); + (m.PhysicalRelease >= start && m.PhysicalRelease <= end) || + (m.DigitalRelease >= start && m.DigitalRelease <= end)); if (!includeUnmonitored) {