From f5692d6cf1d22b00a0e1a108d7b69d93a86c9962 Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sun, 8 Oct 2023 01:41:15 +0300 Subject: [PATCH] Fixed: Show year and fix sorting for collection movies --- .../src/App/State/MovieCollectionAppState.ts | 4 +++- .../src/Collection/CollectionItemConnector.js | 1 + .../src/Collection/Overview/CollectionMovie.js | 9 ++++++--- .../Store/Selectors/createCollectionSelector.js | 17 ----------------- .../Store/Selectors/createCollectionSelector.ts | 17 +++++++++++++++++ .../Collections/CollectionMovieResource.cs | 2 ++ 6 files changed, 29 insertions(+), 21 deletions(-) delete mode 100644 frontend/src/Store/Selectors/createCollectionSelector.js create mode 100644 frontend/src/Store/Selectors/createCollectionSelector.ts diff --git a/frontend/src/App/State/MovieCollectionAppState.ts b/frontend/src/App/State/MovieCollectionAppState.ts index aee45245f..06d143674 100644 --- a/frontend/src/App/State/MovieCollectionAppState.ts +++ b/frontend/src/App/State/MovieCollectionAppState.ts @@ -1,6 +1,8 @@ import AppSectionState from 'App/State/AppSectionState'; import MovieCollection from 'typings/MovieCollection'; -type MovieCollectionAppState = AppSectionState; +interface MovieCollectionAppState extends AppSectionState { + itemMap: Record; +} export default MovieCollectionAppState; diff --git a/frontend/src/Collection/CollectionItemConnector.js b/frontend/src/Collection/CollectionItemConnector.js index 40e801810..64c8ca40a 100644 --- a/frontend/src/Collection/CollectionItemConnector.js +++ b/frontend/src/Collection/CollectionItemConnector.js @@ -21,6 +21,7 @@ function createMapStateToProps() { return { ...collection, + movies: [...collection.movies].sort((a, b) => b.year - a.year), genres: Array.from(new Set(allGenres)).slice(0, 3) }; } diff --git a/frontend/src/Collection/Overview/CollectionMovie.js b/frontend/src/Collection/Overview/CollectionMovie.js index e9b7ac091..f6f754e14 100644 --- a/frontend/src/Collection/Overview/CollectionMovie.js +++ b/frontend/src/Collection/Overview/CollectionMovie.js @@ -61,6 +61,7 @@ class CollectionMovie extends Component { const { id, title, + status, overview, year, tmdbId, @@ -123,11 +124,11 @@ class CollectionMovie extends Component {
- {title} + {title} { year > 0 ? `(${year})` : ''}
{ - id && + id ?
-
+
: + null } @@ -171,6 +173,7 @@ CollectionMovie.propTypes = { id: PropTypes.number, title: PropTypes.string.isRequired, year: PropTypes.number.isRequired, + status: PropTypes.string.isRequired, overview: PropTypes.string.isRequired, monitored: PropTypes.bool, collectionId: PropTypes.number.isRequired, diff --git a/frontend/src/Store/Selectors/createCollectionSelector.js b/frontend/src/Store/Selectors/createCollectionSelector.js deleted file mode 100644 index 0b8717f96..000000000 --- a/frontend/src/Store/Selectors/createCollectionSelector.js +++ /dev/null @@ -1,17 +0,0 @@ -import { createSelector } from 'reselect'; - -function createCollectionSelector() { - return createSelector( - (state, { collectionId }) => collectionId, - (state) => state.movieCollections.itemMap, - (state) => state.movieCollections.items, - (collectionId, itemMap, allCollections) => { - if (allCollections && itemMap && collectionId in itemMap) { - return allCollections[itemMap[collectionId]]; - } - return undefined; - } - ); -} - -export default createCollectionSelector; diff --git a/frontend/src/Store/Selectors/createCollectionSelector.ts b/frontend/src/Store/Selectors/createCollectionSelector.ts new file mode 100644 index 000000000..9b0520227 --- /dev/null +++ b/frontend/src/Store/Selectors/createCollectionSelector.ts @@ -0,0 +1,17 @@ +import { createSelector } from 'reselect'; +import AppState from 'App/State/AppState'; + +function createCollectionSelector() { + return createSelector( + (_: AppState, { collectionId }: { collectionId: number }) => collectionId, + (state: AppState) => state.movieCollections.itemMap, + (state: AppState) => state.movieCollections.items, + (collectionId, itemMap, allCollections) => { + return allCollections && itemMap && collectionId in itemMap + ? allCollections[itemMap[collectionId]] + : undefined; + } + ); +} + +export default createCollectionSelector; diff --git a/src/Radarr.Api.V3/Collections/CollectionMovieResource.cs b/src/Radarr.Api.V3/Collections/CollectionMovieResource.cs index 091bf94e7..9c0af0452 100644 --- a/src/Radarr.Api.V3/Collections/CollectionMovieResource.cs +++ b/src/Radarr.Api.V3/Collections/CollectionMovieResource.cs @@ -12,6 +12,7 @@ public class CollectionMovieResource public string Title { get; set; } public string CleanTitle { get; set; } public string SortTitle { get; set; } + public MovieStatusType Status { get; set; } public string Overview { get; set; } public int Runtime { get; set; } public List Images { get; set; } @@ -37,6 +38,7 @@ public static CollectionMovieResource ToResource(this MovieMetadata model, Movie { TmdbId = model.TmdbId, Title = translatedTitle, + Status = model.Status, Overview = translatedOverview, SortTitle = model.SortTitle, Images = model.Images,