New: Monitor Collections from Movie Details Page

This commit is contained in:
Qstick
2020-07-09 21:43:21 -04:00
parent 9bf50d4493
commit ac79c51196
5 changed files with 181 additions and 3 deletions

View File

@@ -0,0 +1,33 @@
import _ from 'lodash';
import { createSelector } from 'reselect';
function createMovieCollectionListSelector() {
return createSelector(
(state, { tmdbId }) => tmdbId,
(state) => state.settings.netImports.items,
(tmdbId, netImports) => {
const netImportIds = _.reduce(netImports, (acc, list) => {
if (list.implementation === 'TMDbCollectionImport') {
const collectionIdField = list.fields.find((field) => {
return field.name === 'collectionId';
});
if (collectionIdField && parseInt(collectionIdField.value) === tmdbId) {
acc.push(list);
return acc;
}
}
return acc;
}, []);
if (netImportIds.length === 0) {
return undefined;
}
return netImportIds[0];
}
);
}
export default createMovieCollectionListSelector;