Adjust GroupProfileManager

This commit is contained in:
2dust 2026-02-06 14:15:21 +08:00
parent 6167624443
commit 54608ab2b9

View file

@ -12,7 +12,7 @@ public class GroupProfileManager
return await HasCycle(indexId, extraInfo, new HashSet<string>(), new HashSet<string>()); return await HasCycle(indexId, extraInfo, new HashSet<string>(), new HashSet<string>());
} }
public static async Task<bool> HasCycle(string? indexId, ProtocolExtraItem? extraInfo, HashSet<string> visited, HashSet<string> stack) private static async Task<bool> HasCycle(string? indexId, ProtocolExtraItem? extraInfo, HashSet<string> visited, HashSet<string> stack)
{ {
if (indexId.IsNullOrEmpty() || extraInfo == null) if (indexId.IsNullOrEmpty() || extraInfo == null)
{ {
@ -75,20 +75,21 @@ public class GroupProfileManager
return (await GetChildProfileItemsByProtocolExtra(protocolExtra), protocolExtra); return (await GetChildProfileItemsByProtocolExtra(protocolExtra), protocolExtra);
} }
public static async Task<List<ProfileItem>> GetChildProfileItemsByProtocolExtra(ProtocolExtraItem? protocolExtra) private static async Task<List<ProfileItem>> GetChildProfileItemsByProtocolExtra(ProtocolExtraItem? protocolExtra)
{ {
if (protocolExtra == null) if (protocolExtra == null)
{ {
return new(); return new();
} }
var items = await GetSelectedChildProfileItems(protocolExtra);
var subItems = await GetSubChildProfileItems(protocolExtra); var items = new List<ProfileItem>();
items.AddRange(subItems); items.AddRange(await GetSubChildProfileItems(protocolExtra));
items.AddRange(await GetSelectedChildProfileItems(protocolExtra));
return items; return items;
} }
public static async Task<List<ProfileItem>> GetSelectedChildProfileItems(ProtocolExtraItem? extra) private static async Task<List<ProfileItem>> GetSelectedChildProfileItems(ProtocolExtraItem? extra)
{ {
if (extra == null || extra.ChildItems.IsNullOrEmpty()) if (extra == null || extra.ChildItems.IsNullOrEmpty())
{ {
@ -105,10 +106,10 @@ public class GroupProfileManager
p.ConfigType != EConfigType.Custom p.ConfigType != EConfigType.Custom
) )
.ToList(); .ToList();
return childProfiles; return childProfiles ?? new();
} }
public static async Task<List<ProfileItem>> GetSubChildProfileItems(ProtocolExtraItem? extra) private static async Task<List<ProfileItem>> GetSubChildProfileItems(ProtocolExtraItem? extra)
{ {
if (extra == null || extra.SubChildItems.IsNullOrEmpty()) if (extra == null || extra.SubChildItems.IsNullOrEmpty())
{ {