mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-11 20:12:41 +02:00
Fix the sorting on the agenda to respect using all dates instead of only cinema date to sort
This commit is contained in:
parent
aef8a8fd04
commit
6b22481a00
@ -6,9 +6,38 @@ import styles from './Agenda.css';
|
|||||||
|
|
||||||
function Agenda(props) {
|
function Agenda(props) {
|
||||||
const {
|
const {
|
||||||
items
|
items,
|
||||||
|
start,
|
||||||
|
end
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
const startDateParsed = Date.parse(start);
|
||||||
|
const endDateParsed = Date.parse(end);
|
||||||
|
|
||||||
|
items.forEach((item) => {
|
||||||
|
const cinemaDateParsed = Date.parse(item.inCinemas);
|
||||||
|
const digitalDateParsed = Date.parse(item.digitalRelease);
|
||||||
|
const physicalDateParsed = Date.parse(item.physicalRelease);
|
||||||
|
const dates = [];
|
||||||
|
|
||||||
|
if (cinemaDateParsed > 0 && cinemaDateParsed >= startDateParsed && cinemaDateParsed <= endDateParsed) {
|
||||||
|
dates.push(cinemaDateParsed);
|
||||||
|
}
|
||||||
|
if (digitalDateParsed > 0 && digitalDateParsed >= startDateParsed && digitalDateParsed <= endDateParsed) {
|
||||||
|
dates.push(digitalDateParsed);
|
||||||
|
}
|
||||||
|
if (physicalDateParsed > 0 && physicalDateParsed >= startDateParsed && physicalDateParsed <= endDateParsed) {
|
||||||
|
dates.push(physicalDateParsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
item.sortDate = Math.min(...dates);
|
||||||
|
item.cinemaDateParsed = cinemaDateParsed;
|
||||||
|
item.digitalDateParsed = digitalDateParsed;
|
||||||
|
item.physicalDateParsed = physicalDateParsed;
|
||||||
|
});
|
||||||
|
|
||||||
|
items.sort((a, b) => ((a.sortDate > b.sortDate) ? 1 : -1));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.agenda}>
|
<div className={styles.agenda}>
|
||||||
{
|
{
|
||||||
@ -32,7 +61,9 @@ function Agenda(props) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Agenda.propTypes = {
|
Agenda.propTypes = {
|
||||||
items: PropTypes.arrayOf(PropTypes.object).isRequired
|
items: PropTypes.arrayOf(PropTypes.object).isRequired,
|
||||||
|
start: PropTypes.string.isRequired,
|
||||||
|
end: PropTypes.string.isRequired
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Agenda;
|
export default Agenda;
|
||||||
|
@ -92,6 +92,5 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.dateIcon {
|
.dateIcon {
|
||||||
display: inline;
|
width: 25px;
|
||||||
margin-right: 10px;
|
|
||||||
}
|
}
|
||||||
|
@ -55,23 +55,26 @@ class AgendaEvent extends Component {
|
|||||||
showCutoffUnmetIcon,
|
showCutoffUnmetIcon,
|
||||||
longDateFormat,
|
longDateFormat,
|
||||||
colorImpairedMode,
|
colorImpairedMode,
|
||||||
startDate,
|
cinemaDateParsed,
|
||||||
endDate
|
digitalDateParsed,
|
||||||
|
physicalDateParsed,
|
||||||
|
sortDate
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
const agendaStart = Date.parse(startDate);
|
let startTime = null;
|
||||||
const agendaEnd = Date.parse(endDate);
|
let releaseIcon = null;
|
||||||
const cinemaDate = Date.parse(inCinemas);
|
|
||||||
const digitalDate = Date.parse(digitalRelease);
|
|
||||||
let startTime = physicalRelease;
|
|
||||||
let releaseIcon = icons.DISC;
|
|
||||||
|
|
||||||
if (digitalDate >= agendaStart && digitalDate <= agendaEnd) {
|
if (physicalDateParsed === sortDate) {
|
||||||
|
startTime = physicalRelease;
|
||||||
|
releaseIcon = icons.DISC;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (digitalDateParsed === sortDate) {
|
||||||
startTime = digitalRelease;
|
startTime = digitalRelease;
|
||||||
releaseIcon = icons.MOVIE_FILE;
|
releaseIcon = icons.MOVIE_FILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cinemaDate >= agendaStart && cinemaDate <= agendaEnd) {
|
if (cinemaDateParsed === sortDate) {
|
||||||
startTime = inCinemas;
|
startTime = inCinemas;
|
||||||
releaseIcon = icons.IN_CINEMAS;
|
releaseIcon = icons.IN_CINEMAS;
|
||||||
}
|
}
|
||||||
@ -92,13 +95,14 @@ class AgendaEvent extends Component {
|
|||||||
)}
|
)}
|
||||||
to={link}
|
to={link}
|
||||||
>
|
>
|
||||||
|
<div className={styles.dateIcon}>
|
||||||
|
<Icon
|
||||||
|
name={releaseIcon}
|
||||||
|
kind={kinds.DEFAULT}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className={styles.date}>
|
<div className={styles.date}>
|
||||||
<div className={styles.dateIcon}>
|
|
||||||
<Icon
|
|
||||||
name={releaseIcon}
|
|
||||||
kind={kinds.DEFAULT}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{(showDate) ? startTime.format(longDateFormat) : null}
|
{(showDate) ? startTime.format(longDateFormat) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -176,8 +180,10 @@ AgendaEvent.propTypes = {
|
|||||||
timeFormat: PropTypes.string.isRequired,
|
timeFormat: PropTypes.string.isRequired,
|
||||||
longDateFormat: PropTypes.string.isRequired,
|
longDateFormat: PropTypes.string.isRequired,
|
||||||
colorImpairedMode: PropTypes.bool.isRequired,
|
colorImpairedMode: PropTypes.bool.isRequired,
|
||||||
startDate: PropTypes.date,
|
cinemaDateParsed: PropTypes.number,
|
||||||
endDate: PropTypes.date
|
digitalDateParsed: PropTypes.number,
|
||||||
|
physicalDateParsed: PropTypes.number,
|
||||||
|
sortDate: PropTypes.number
|
||||||
};
|
};
|
||||||
|
|
||||||
AgendaEvent.defaultProps = {
|
AgendaEvent.defaultProps = {
|
||||||
|
@ -13,9 +13,7 @@ function createMapStateToProps() {
|
|||||||
createMovieFileSelector(),
|
createMovieFileSelector(),
|
||||||
createQueueItemSelector(),
|
createQueueItemSelector(),
|
||||||
createUISettingsSelector(),
|
createUISettingsSelector(),
|
||||||
(state) => state.calendar.start,
|
(calendarOptions, movie, movieFile, queueItem, uiSettings) => {
|
||||||
(state) => state.calendar.end,
|
|
||||||
(calendarOptions, movie, movieFile, queueItem, uiSettings, startDate, endDate) => {
|
|
||||||
return {
|
return {
|
||||||
movie,
|
movie,
|
||||||
movieFile,
|
movieFile,
|
||||||
@ -23,9 +21,7 @@ function createMapStateToProps() {
|
|||||||
...calendarOptions,
|
...calendarOptions,
|
||||||
timeFormat: uiSettings.timeFormat,
|
timeFormat: uiSettings.timeFormat,
|
||||||
longDateFormat: uiSettings.longDateFormat,
|
longDateFormat: uiSettings.longDateFormat,
|
||||||
colorImpairedMode: uiSettings.enableColorImpairedMode,
|
colorImpairedMode: uiSettings.enableColorImpairedMode
|
||||||
startDate,
|
|
||||||
endDate
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -24,7 +24,7 @@ function getTitle(time, start, end, view, longDateFormat) {
|
|||||||
} else if (view === 'month') {
|
} else if (view === 'month') {
|
||||||
return timeMoment.format('MMMM YYYY');
|
return timeMoment.format('MMMM YYYY');
|
||||||
} else if (view === 'agenda') {
|
} else if (view === 'agenda') {
|
||||||
return 'Agenda';
|
return `Agenda: ${startMoment.format('MMM D')} - ${endMoment.format('MMM D')}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let startFormat = 'MMM D YYYY';
|
let startFormat = 'MMM D YYYY';
|
||||||
|
Loading…
Reference in New Issue
Block a user