2018-11-23 07:04:42 +00:00
|
|
|
import { connect } from 'react-redux';
|
|
|
|
import { createSelector } from 'reselect';
|
|
|
|
import createAllMoviesSelector from 'Store/Selectors/createAllMoviesSelector';
|
|
|
|
import TagDetailsModalContent from './TagDetailsModalContent';
|
|
|
|
|
|
|
|
function findMatchingItems(ids, items) {
|
|
|
|
return items.filter((s) => {
|
|
|
|
return ids.includes(s.id);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-05-20 02:08:29 +00:00
|
|
|
function createUnorderedMatchingMoviesSelector() {
|
2018-11-23 07:04:42 +00:00
|
|
|
return createSelector(
|
|
|
|
(state, { movieIds }) => movieIds,
|
|
|
|
createAllMoviesSelector(),
|
|
|
|
findMatchingItems
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-05-20 02:08:29 +00:00
|
|
|
function createMatchingMoviesSelector() {
|
|
|
|
return createSelector(
|
|
|
|
createUnorderedMatchingMoviesSelector(),
|
|
|
|
(movies) => {
|
|
|
|
return movies.sort((movieA, movieB) => {
|
|
|
|
const sortTitleA = movieA.sortTitle;
|
|
|
|
const sortTitleB = movieB.sortTitle;
|
|
|
|
|
|
|
|
if (sortTitleA > sortTitleB) {
|
|
|
|
return 1;
|
|
|
|
} else if (sortTitleA < sortTitleB) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-11-23 07:04:42 +00:00
|
|
|
function createMatchingDelayProfilesSelector() {
|
|
|
|
return createSelector(
|
|
|
|
(state, { delayProfileIds }) => delayProfileIds,
|
|
|
|
(state) => state.settings.delayProfiles.items,
|
|
|
|
findMatchingItems
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function createMatchingNotificationsSelector() {
|
|
|
|
return createSelector(
|
|
|
|
(state, { notificationIds }) => notificationIds,
|
|
|
|
(state) => state.settings.notifications.items,
|
|
|
|
findMatchingItems
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function createMatchingRestrictionsSelector() {
|
|
|
|
return createSelector(
|
|
|
|
(state, { restrictionIds }) => restrictionIds,
|
|
|
|
(state) => state.settings.restrictions.items,
|
|
|
|
findMatchingItems
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-09-04 02:50:56 +00:00
|
|
|
function createMatchingImportListsSelector() {
|
2019-11-02 01:31:47 +00:00
|
|
|
return createSelector(
|
2020-09-04 02:50:56 +00:00
|
|
|
(state, { importListIds }) => importListIds,
|
|
|
|
(state) => state.settings.importLists.items,
|
2019-11-02 01:31:47 +00:00
|
|
|
findMatchingItems
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2021-03-22 00:00:06 +00:00
|
|
|
function createMatchingIndexersSelector() {
|
|
|
|
return createSelector(
|
|
|
|
(state, { indexerIds }) => indexerIds,
|
|
|
|
(state) => state.settings.indexers.items,
|
|
|
|
findMatchingItems
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-07-11 03:51:14 +00:00
|
|
|
function createMatchingDownloadClientsSelector() {
|
|
|
|
return createSelector(
|
|
|
|
(state, { downloadClientIds }) => downloadClientIds,
|
|
|
|
(state) => state.settings.downloadClients.items,
|
|
|
|
findMatchingItems
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-12-06 06:58:53 +00:00
|
|
|
function createMatchingAutoTagsSelector() {
|
|
|
|
return createSelector(
|
|
|
|
(state, { autoTagIds }) => autoTagIds,
|
|
|
|
(state) => state.settings.autoTaggings.items,
|
|
|
|
findMatchingItems
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2018-11-23 07:04:42 +00:00
|
|
|
function createMapStateToProps() {
|
|
|
|
return createSelector(
|
2020-05-20 02:08:29 +00:00
|
|
|
createMatchingMoviesSelector(),
|
2018-11-23 07:04:42 +00:00
|
|
|
createMatchingDelayProfilesSelector(),
|
|
|
|
createMatchingNotificationsSelector(),
|
|
|
|
createMatchingRestrictionsSelector(),
|
2020-09-04 02:50:56 +00:00
|
|
|
createMatchingImportListsSelector(),
|
2021-03-22 00:00:06 +00:00
|
|
|
createMatchingIndexersSelector(),
|
2023-07-11 03:51:14 +00:00
|
|
|
createMatchingDownloadClientsSelector(),
|
2022-12-06 06:58:53 +00:00
|
|
|
createMatchingAutoTagsSelector(),
|
|
|
|
(movies, delayProfiles, notifications, restrictions, importLists, indexers, downloadClients, autoTags) => {
|
2018-11-23 07:04:42 +00:00
|
|
|
return {
|
|
|
|
movies,
|
|
|
|
delayProfiles,
|
|
|
|
notifications,
|
2019-11-02 01:31:47 +00:00
|
|
|
restrictions,
|
2021-03-22 00:00:06 +00:00
|
|
|
importLists,
|
2023-07-11 03:51:14 +00:00
|
|
|
indexers,
|
2022-12-06 06:58:53 +00:00
|
|
|
downloadClients,
|
|
|
|
autoTags
|
2018-11-23 07:04:42 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default connect(createMapStateToProps)(TagDetailsModalContent);
|