Fixed: Prevent delete of last profile

pull/918/head
Qstick 3 years ago
parent 627da14a32
commit 69de6d18eb

@ -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;
}

@ -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);
}

Loading…
Cancel
Save