From 69de6d18eb6d7730df48f91152ae2e7bea58910b Mon Sep 17 00:00:00 2001 From: Qstick Date: Fri, 25 Mar 2022 18:53:29 -0500 Subject: [PATCH] Fixed: Prevent delete of last profile --- frontend/src/Store/Selectors/createProfileInUseSelector.js | 5 +++-- src/NzbDrone.Core/Profiles/AppSyncProfileService.cs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/frontend/src/Store/Selectors/createProfileInUseSelector.js b/frontend/src/Store/Selectors/createProfileInUseSelector.js index d9445e361..807bf4673 100644 --- a/frontend/src/Store/Selectors/createProfileInUseSelector.js +++ b/frontend/src/Store/Selectors/createProfileInUseSelector.js @@ -5,13 +5,14 @@ import createAllIndexersSelector from './createAllIndexersSelector'; function createProfileInUseSelector(profileProp) { return createSelector( (state, { id }) => id, + (state) => state.settings.appProfiles.items, createAllIndexersSelector(), - (id, indexers) => { + (id, profiles, indexers) => { if (!id) { return false; } - if (_.some(indexers, { [profileProp]: id })) { + if (_.some(indexers, { [profileProp]: id }) || profiles.length <= 1) { return true; } diff --git a/src/NzbDrone.Core/Profiles/AppSyncProfileService.cs b/src/NzbDrone.Core/Profiles/AppSyncProfileService.cs index 1ece1dab4..952a06d8e 100644 --- a/src/NzbDrone.Core/Profiles/AppSyncProfileService.cs +++ b/src/NzbDrone.Core/Profiles/AppSyncProfileService.cs @@ -46,7 +46,7 @@ namespace NzbDrone.Core.Profiles 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); }