From 28c566a071665a723a1f324aa2b6bccc88a4e0cd Mon Sep 17 00:00:00 2001 From: Bogdan Date: Sat, 9 Sep 2023 15:36:57 +0300 Subject: [PATCH] Hide obsolete indexer flags from UI --- .../Indexers/IndexerFlagController.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Radarr.Api.V3/Indexers/IndexerFlagController.cs b/src/Radarr.Api.V3/Indexers/IndexerFlagController.cs index e0e48f9bc..a70bcfc3f 100644 --- a/src/Radarr.Api.V3/Indexers/IndexerFlagController.cs +++ b/src/Radarr.Api.V3/Indexers/IndexerFlagController.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Mvc; +using NzbDrone.Common.Extensions; using NzbDrone.Core.Parser.Model; using Radarr.Http; @@ -13,11 +14,16 @@ namespace Radarr.Api.V3.Indexers [HttpGet] public List GetAll() { - return Enum.GetValues(typeof(IndexerFlags)).Cast().Select(f => new IndexerFlagResource - { - Id = (int)f, - Name = f.ToString() - }).ToList(); + var type = typeof(IndexerFlags); + + return Enum.GetValues(type) + .Cast() + .Where(f => type.GetField(f.ToString())?.GetCustomAttributes(false).OfType().Empty() ?? true) + .Select(f => new IndexerFlagResource + { + Id = (int)f, + Name = f.ToString() + }).ToList(); } } }