mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-27 12:33:00 +02:00
New: App Sync Profiles
This commit is contained in:
15
frontend/src/Store/Selectors/createAppProfileSelector.js
Normal file
15
frontend/src/Store/Selectors/createAppProfileSelector.js
Normal file
@@ -0,0 +1,15 @@
|
||||
import { createSelector } from 'reselect';
|
||||
|
||||
function createAppProfileSelector() {
|
||||
return createSelector(
|
||||
(state, { appProfileId }) => appProfileId,
|
||||
(state) => state.settings.appProfiles.items,
|
||||
(appProfileId, appProfiles) => {
|
||||
return appProfiles.find((profile) => {
|
||||
return profile.id === appProfileId;
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default createAppProfileSelector;
|
@@ -0,0 +1,16 @@
|
||||
import { createSelector } from 'reselect';
|
||||
import createIndexerSelector from './createIndexerSelector';
|
||||
|
||||
function createIndexerAppProfileSelector() {
|
||||
return createSelector(
|
||||
(state) => state.settings.appProfiles.items,
|
||||
createIndexerSelector(),
|
||||
(appProfiles, indexer = {}) => {
|
||||
return appProfiles.find((profile) => {
|
||||
return profile.id === indexer.appProfileId;
|
||||
});
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default createIndexerAppProfileSelector;
|
23
frontend/src/Store/Selectors/createProfileInUseSelector.js
Normal file
23
frontend/src/Store/Selectors/createProfileInUseSelector.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import _ from 'lodash';
|
||||
import { createSelector } from 'reselect';
|
||||
import createAllIndexersSelector from './createAllIndexersSelector';
|
||||
|
||||
function createProfileInUseSelector(profileProp) {
|
||||
return createSelector(
|
||||
(state, { id }) => id,
|
||||
createAllIndexersSelector(),
|
||||
(id, indexers) => {
|
||||
if (!id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_.some(indexers, { [profileProp]: id })) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
export default createProfileInUseSelector;
|
Reference in New Issue
Block a user