mirror of
https://github.com/2dust/v2rayN.git
synced 2026-03-12 19:33:01 +00:00
parent
9f6237fb21
commit
a71ebbd01c
9 changed files with 32 additions and 64 deletions
|
|
@ -248,6 +248,24 @@ public sealed class AppManager
|
|||
return items.ToDictionary(it => it.IndexId);
|
||||
}
|
||||
|
||||
public async Task<List<ProfileItem>> GetProfileItemsOrderedByIndexIds(IEnumerable<string> indexIds)
|
||||
{
|
||||
var idList = indexIds.Where(id => !id.IsNullOrEmpty()).Distinct().ToList();
|
||||
if (idList.Count == 0)
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
var items = await SQLiteHelper.Instance.TableAsync<ProfileItem>()
|
||||
.Where(it => idList.Contains(it.IndexId))
|
||||
.ToListAsync();
|
||||
var itemMap = items.ToDictionary(it => it.IndexId);
|
||||
|
||||
return idList.Select(id => itemMap.GetValueOrDefault(id))
|
||||
.Where(item => item != null)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public async Task<ProfileItem?> GetProfileItemViaRemarks(string? remarks)
|
||||
{
|
||||
if (remarks.IsNullOrEmpty())
|
||||
|
|
|
|||
|
|
@ -52,10 +52,10 @@ public class GroupProfileManager
|
|||
return false;
|
||||
}
|
||||
|
||||
foreach (var child in childIds)
|
||||
var childItems = await AppManager.Instance.GetProfileItemsByIndexIds(childIds);
|
||||
foreach (var childItem in childItems)
|
||||
{
|
||||
var childItem = await AppManager.Instance.GetProfileItem(child);
|
||||
if (await HasCycle(child, childItem?.GetProtocolExtra(), visited, stack))
|
||||
if (await HasCycle(childItem.IndexId, childItem?.GetProtocolExtra(), visited, stack))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -103,17 +103,7 @@ public class GroupProfileManager
|
|||
return [];
|
||||
}
|
||||
|
||||
var profileMap = await AppManager.Instance.GetProfileItemsByIndexIdsAsMap(childProfileIds);
|
||||
|
||||
var ordered = new List<ProfileItem>(childProfileIds.Count);
|
||||
foreach (var id in childProfileIds)
|
||||
{
|
||||
if (id != null && profileMap.TryGetValue(id, out var item) && item != null)
|
||||
{
|
||||
ordered.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
var ordered = await AppManager.Instance.GetProfileItemsOrderedByIndexIds(childProfileIds);
|
||||
return ordered;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -99,15 +99,8 @@ public class AddGroupServerViewModel : MyReactiveObject
|
|||
Filter = protocolExtra?.Filter;
|
||||
|
||||
var childIndexIds = Utils.String2List(protocolExtra?.ChildItems) ?? [];
|
||||
foreach (var item in childIndexIds)
|
||||
{
|
||||
var child = await AppManager.Instance.GetProfileItem(item);
|
||||
if (child == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ChildItemsObs.Add(child);
|
||||
}
|
||||
var childItemList = await AppManager.Instance.GetProfileItemsOrderedByIndexIds(childIndexIds);
|
||||
ChildItemsObs.AddRange(childItemList);
|
||||
}
|
||||
|
||||
public async Task ChildRemoveAsync()
|
||||
|
|
|
|||
|
|
@ -255,19 +255,7 @@ public class ProfilesSelectViewModel : MyReactiveObject
|
|||
{
|
||||
return null;
|
||||
}
|
||||
var lst = new List<ProfileItem>();
|
||||
foreach (var sp in SelectedProfiles)
|
||||
{
|
||||
if (string.IsNullOrEmpty(sp?.IndexId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
var item = await AppManager.Instance.GetProfileItem(sp.IndexId);
|
||||
if (item != null)
|
||||
{
|
||||
lst.Add(item);
|
||||
}
|
||||
}
|
||||
var lst = await AppManager.Instance.GetProfileItemsOrderedByIndexIds(SelectedProfiles.Select(sp => sp?.IndexId));
|
||||
if (lst.Count == 0)
|
||||
{
|
||||
NoticeManager.Instance.Enqueue(ResUI.PleaseSelectServer);
|
||||
|
|
|
|||
|
|
@ -456,14 +456,7 @@ public class ProfilesViewModel : MyReactiveObject
|
|||
var orderProfiles = SelectedProfiles?.OrderBy(t => t.Sort);
|
||||
if (latest)
|
||||
{
|
||||
foreach (var profile in orderProfiles)
|
||||
{
|
||||
var item = await AppManager.Instance.GetProfileItem(profile.IndexId);
|
||||
if (item is not null)
|
||||
{
|
||||
lstSelected.Add(item);
|
||||
}
|
||||
}
|
||||
lstSelected.AddRange(await AppManager.Instance.GetProfileItemsOrderedByIndexIds(orderProfiles.Select(sp => sp?.IndexId)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -148,14 +148,7 @@ public partial class AddGroupServerWindow : WindowBase<AddGroupServerViewModel>
|
|||
private async void MenuAddChild_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectWindow = new ProfilesSelectWindow();
|
||||
if (ViewModel?.SelectedSource?.ConfigType == EConfigType.PolicyGroup)
|
||||
{
|
||||
selectWindow.SetConfigTypeFilter(new[] { EConfigType.Custom }, exclude: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectWindow.SetConfigTypeFilter(new[] { EConfigType.Custom, EConfigType.PolicyGroup, EConfigType.ProxyChain }, exclude: true);
|
||||
}
|
||||
selectWindow.SetConfigTypeFilter([EConfigType.Custom], exclude: true);
|
||||
selectWindow.AllowMultiSelect(true);
|
||||
var result = await selectWindow.ShowDialog<bool?>(this);
|
||||
if (result == true)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public partial class SubEditWindow : WindowBase<SubEditViewModel>
|
|||
private async void BtnSelectPrevProfile_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectWindow = new ProfilesSelectWindow();
|
||||
selectWindow.SetConfigTypeFilter(new[] { EConfigType.Custom, EConfigType.PolicyGroup, EConfigType.ProxyChain }, exclude: true);
|
||||
selectWindow.SetConfigTypeFilter([EConfigType.Custom], exclude: true);
|
||||
var result = await selectWindow.ShowDialog<bool?>(this);
|
||||
if (result == true)
|
||||
{
|
||||
|
|
@ -74,7 +74,7 @@ public partial class SubEditWindow : WindowBase<SubEditViewModel>
|
|||
private async void BtnSelectNextProfile_Click(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectWindow = new ProfilesSelectWindow();
|
||||
selectWindow.SetConfigTypeFilter(new[] { EConfigType.Custom, EConfigType.PolicyGroup, EConfigType.ProxyChain }, exclude: true);
|
||||
selectWindow.SetConfigTypeFilter([EConfigType.Custom], exclude: true);
|
||||
var result = await selectWindow.ShowDialog<bool?>(this);
|
||||
if (result == true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -128,14 +128,7 @@ public partial class AddGroupServerWindow
|
|||
private async void MenuAddChild_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectWindow = new ProfilesSelectWindow();
|
||||
if (ViewModel?.SelectedSource?.ConfigType == EConfigType.PolicyGroup)
|
||||
{
|
||||
selectWindow.SetConfigTypeFilter(new[] { EConfigType.Custom }, exclude: true);
|
||||
}
|
||||
else
|
||||
{
|
||||
selectWindow.SetConfigTypeFilter(new[] { EConfigType.Custom, EConfigType.PolicyGroup, EConfigType.ProxyChain }, exclude: true);
|
||||
}
|
||||
selectWindow.SetConfigTypeFilter([EConfigType.Custom], exclude: true);
|
||||
selectWindow.AllowMultiSelect(true);
|
||||
if (selectWindow.ShowDialog() == true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public partial class SubEditWindow
|
|||
private async void BtnSelectPrevProfile_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectWindow = new ProfilesSelectWindow();
|
||||
selectWindow.SetConfigTypeFilter(new[] { EConfigType.Custom, EConfigType.PolicyGroup, EConfigType.ProxyChain }, exclude: true);
|
||||
selectWindow.SetConfigTypeFilter([EConfigType.Custom], exclude: true);
|
||||
if (selectWindow.ShowDialog() == true)
|
||||
{
|
||||
var profile = await selectWindow.ProfileItem;
|
||||
|
|
@ -67,7 +67,7 @@ public partial class SubEditWindow
|
|||
private async void BtnSelectNextProfile_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var selectWindow = new ProfilesSelectWindow();
|
||||
selectWindow.SetConfigTypeFilter(new[] { EConfigType.Custom, EConfigType.PolicyGroup, EConfigType.ProxyChain }, exclude: true);
|
||||
selectWindow.SetConfigTypeFilter([EConfigType.Custom], exclude: true);
|
||||
if (selectWindow.ShowDialog() == true)
|
||||
{
|
||||
var profile = await selectWindow.ProfileItem;
|
||||
|
|
|
|||
Loading…
Reference in a new issue