mirror of
https://github.com/Prowlarr/Prowlarr
synced 2025-12-06 08:34:28 +01:00
Fixed: Prevent delete of last profile
This commit is contained in:
parent
627da14a32
commit
69de6d18eb
2 changed files with 4 additions and 3 deletions
|
|
@ -5,13 +5,14 @@ import createAllIndexersSelector from './createAllIndexersSelector';
|
||||||
function createProfileInUseSelector(profileProp) {
|
function createProfileInUseSelector(profileProp) {
|
||||||
return createSelector(
|
return createSelector(
|
||||||
(state, { id }) => id,
|
(state, { id }) => id,
|
||||||
|
(state) => state.settings.appProfiles.items,
|
||||||
createAllIndexersSelector(),
|
createAllIndexersSelector(),
|
||||||
(id, indexers) => {
|
(id, profiles, indexers) => {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_.some(indexers, { [profileProp]: id })) {
|
if (_.some(indexers, { [profileProp]: id }) || profiles.length <= 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ public void Update(AppSyncProfile profile)
|
||||||
|
|
||||||
public void Delete(int id)
|
public void Delete(int id)
|
||||||
{
|
{
|
||||||
if (_indexerFactory.All().Any(c => c.AppProfileId == id))
|
if (_indexerFactory.All().Any(c => c.AppProfileId == id) || All().Count == 1)
|
||||||
{
|
{
|
||||||
throw new ProfileInUseException(id);
|
throw new ProfileInUseException(id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue