From 1b79d2f56040eb98e2ad2d4446ebc8043e38903a Mon Sep 17 00:00:00 2001 From: DHR60 Date: Thu, 5 Feb 2026 16:23:50 +0800 Subject: [PATCH] Fix group --- .../ServiceLib/Manager/GroupProfileManager.cs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/v2rayN/ServiceLib/Manager/GroupProfileManager.cs b/v2rayN/ServiceLib/Manager/GroupProfileManager.cs index ce7341dc..3c9d766e 100644 --- a/v2rayN/ServiceLib/Manager/GroupProfileManager.cs +++ b/v2rayN/ServiceLib/Manager/GroupProfileManager.cs @@ -72,21 +72,30 @@ public class GroupProfileManager public static async Task<(List Items, ProtocolExtraItem? Extra)> GetChildProfileItems(ProfileItem profileItem) { var protocolExtra = profileItem?.GetProtocolExtra(); - var items = await GetChildProfileItems(protocolExtra); + return (await GetChildProfileItemsByProtocolExtra(protocolExtra), protocolExtra); + } + + public static async Task> GetChildProfileItemsByProtocolExtra(ProtocolExtraItem? protocolExtra) + { + if (protocolExtra == null) + { + return new(); + } + var items = await GetSelectedChildProfileItems(protocolExtra); var subItems = await GetSubChildProfileItems(protocolExtra); items.AddRange(subItems); - return (items, protocolExtra); + return items; } - public static async Task> GetChildProfileItems(ProtocolExtraItem? extra) + public static async Task> GetSelectedChildProfileItems(ProtocolExtraItem? extra) { if (extra == null || extra.ChildItems.IsNullOrEmpty()) { return new(); } var childProfiles = (await Task.WhenAll( - Utils.String2List(extra.ChildItems) + (Utils.String2List(extra.ChildItems) ?? new()) .Where(p => !p.IsNullOrEmpty()) .Select(AppManager.Instance.GetProfileItem) )) @@ -101,19 +110,19 @@ public class GroupProfileManager public static async Task> GetSubChildProfileItems(ProtocolExtraItem? extra) { - if (extra == null || extra.Filter.IsNullOrEmpty()) + if (extra == null || extra.SubChildItems.IsNullOrEmpty()) { return new(); } var childProfiles = await AppManager.Instance.ProfileItems(extra.SubChildItems ?? string.Empty); - return childProfiles.Where(p => + return childProfiles?.Where(p => p != null && p.IsValid() && !p.ConfigType.IsComplexType() && (extra.Filter.IsNullOrEmpty() || Regex.IsMatch(p.Remarks, extra.Filter)) ) - .ToList(); + .ToList() ?? new(); } public static async Task> GetAllChildDomainAddresses(ProfileItem profileItem)