mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-13 11:59:13 +00:00
Rename ProfileGroupItem.ParentIndexId to IndexId
Because ProfileGroupItem is an extension of ProfileItem, it is better to name the fields the same way.
This commit is contained in:
parent
0a1d6db9d1
commit
f76fd364a2
5 changed files with 19 additions and 19 deletions
|
@ -1098,7 +1098,7 @@ public static class ConfigHandler
|
||||||
await SQLiteHelper.Instance.ReplaceAsync(profileItem);
|
await SQLiteHelper.Instance.ReplaceAsync(profileItem);
|
||||||
if (profileGroupItem != null)
|
if (profileGroupItem != null)
|
||||||
{
|
{
|
||||||
profileGroupItem.ParentIndexId = profileItem.IndexId;
|
profileGroupItem.IndexId = profileItem.IndexId;
|
||||||
await ProfileGroupItemManager.Instance.SaveItemAsync(profileGroupItem);
|
await ProfileGroupItemManager.Instance.SaveItemAsync(profileGroupItem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1233,7 +1233,7 @@ public static class ConfigHandler
|
||||||
{
|
{
|
||||||
ChildItems = childProfileIndexId,
|
ChildItems = childProfileIndexId,
|
||||||
MultipleLoad = multipleLoad,
|
MultipleLoad = multipleLoad,
|
||||||
ParentIndexId = indexId,
|
IndexId = indexId,
|
||||||
};
|
};
|
||||||
var ret = await AddGroupServerCommon(config, profile, profileGroup, true);
|
var ret = await AddGroupServerCommon(config, profile, profileGroup, true);
|
||||||
result.Success = ret == 0;
|
result.Success = ret == 0;
|
||||||
|
|
|
@ -208,13 +208,13 @@ public sealed class AppManager
|
||||||
return await SQLiteHelper.Instance.TableAsync<ProfileItem>().FirstOrDefaultAsync(it => it.Remarks == remarks);
|
return await SQLiteHelper.Instance.TableAsync<ProfileItem>().FirstOrDefaultAsync(it => it.Remarks == remarks);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<ProfileGroupItem?> GetProfileGroupItem(string parentIndexId)
|
public async Task<ProfileGroupItem?> GetProfileGroupItem(string indexId)
|
||||||
{
|
{
|
||||||
if (parentIndexId.IsNullOrEmpty())
|
if (indexId.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().FirstOrDefaultAsync(it => it.ParentIndexId == parentIndexId);
|
return await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().FirstOrDefaultAsync(it => it.IndexId == indexId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<RoutingItem>?> RoutingItems()
|
public async Task<List<RoutingItem>?> RoutingItems()
|
||||||
|
|
|
@ -38,17 +38,17 @@ public class ProfileGroupItemManager
|
||||||
|
|
||||||
private async Task InitData()
|
private async Task InitData()
|
||||||
{
|
{
|
||||||
await SQLiteHelper.Instance.ExecuteAsync($"delete from ProfileGroupItem where parentIndexId not in ( select indexId from ProfileItem )");
|
await SQLiteHelper.Instance.ExecuteAsync($"delete from ProfileGroupItem where IndexId not in ( select indexId from ProfileItem )");
|
||||||
|
|
||||||
var list = await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().ToListAsync();
|
var list = await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().ToListAsync();
|
||||||
_items = new ConcurrentDictionary<string, ProfileGroupItem>(list.Where(t => !string.IsNullOrEmpty(t.ParentIndexId)).ToDictionary(t => t.ParentIndexId!));
|
_items = new ConcurrentDictionary<string, ProfileGroupItem>(list.Where(t => !string.IsNullOrEmpty(t.IndexId)).ToDictionary(t => t.IndexId!));
|
||||||
}
|
}
|
||||||
|
|
||||||
private ProfileGroupItem AddProfileGroupItem(string indexId)
|
private ProfileGroupItem AddProfileGroupItem(string indexId)
|
||||||
{
|
{
|
||||||
var profileGroupItem = new ProfileGroupItem()
|
var profileGroupItem = new ProfileGroupItem()
|
||||||
{
|
{
|
||||||
ParentIndexId = indexId,
|
IndexId = indexId,
|
||||||
ChildItems = string.Empty,
|
ChildItems = string.Empty,
|
||||||
MultipleLoad = EMultipleLoad.LeastPing
|
MultipleLoad = EMultipleLoad.LeastPing
|
||||||
};
|
};
|
||||||
|
@ -78,19 +78,19 @@ public class ProfileGroupItemManager
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var lstExists = await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().ToListAsync();
|
var lstExists = await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().ToListAsync();
|
||||||
var existsMap = lstExists.Where(t => !string.IsNullOrEmpty(t.ParentIndexId)).ToDictionary(t => t.ParentIndexId!);
|
var existsMap = lstExists.Where(t => !string.IsNullOrEmpty(t.IndexId)).ToDictionary(t => t.IndexId!);
|
||||||
|
|
||||||
var lstInserts = new List<ProfileGroupItem>();
|
var lstInserts = new List<ProfileGroupItem>();
|
||||||
var lstUpdates = new List<ProfileGroupItem>();
|
var lstUpdates = new List<ProfileGroupItem>();
|
||||||
|
|
||||||
foreach (var item in _items.Values)
|
foreach (var item in _items.Values)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(item.ParentIndexId))
|
if (string.IsNullOrEmpty(item.IndexId))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (existsMap.ContainsKey(item.ParentIndexId))
|
if (existsMap.ContainsKey(item.IndexId))
|
||||||
{
|
{
|
||||||
lstUpdates.Add(item);
|
lstUpdates.Add(item);
|
||||||
}
|
}
|
||||||
|
@ -140,16 +140,16 @@ public class ProfileGroupItemManager
|
||||||
throw new ArgumentNullException(nameof(item));
|
throw new ArgumentNullException(nameof(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(item.ParentIndexId))
|
if (string.IsNullOrWhiteSpace(item.IndexId))
|
||||||
{
|
{
|
||||||
throw new ArgumentException("ParentIndexId required", nameof(item));
|
throw new ArgumentException("IndexId required", nameof(item));
|
||||||
}
|
}
|
||||||
|
|
||||||
_items[item.ParentIndexId] = item;
|
_items[item.IndexId] = item;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var lst = await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().Where(t => t.ParentIndexId == item.ParentIndexId).ToListAsync();
|
var lst = await SQLiteHelper.Instance.TableAsync<ProfileGroupItem>().Where(t => t.IndexId == item.IndexId).ToListAsync();
|
||||||
if (lst != null && lst.Count > 0)
|
if (lst != null && lst.Count > 0)
|
||||||
{
|
{
|
||||||
await SQLiteHelper.Instance.UpdateAllAsync(new List<ProfileGroupItem> { item });
|
await SQLiteHelper.Instance.UpdateAllAsync(new List<ProfileGroupItem> { item });
|
||||||
|
@ -250,11 +250,11 @@ public class ProfileGroupItemManager
|
||||||
return childProfiles;
|
return childProfiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<HashSet<string>> GetAllChildDomainAddresses(string parentIndexId)
|
public static async Task<HashSet<string>> GetAllChildDomainAddresses(string indexId)
|
||||||
{
|
{
|
||||||
// include grand children
|
// include grand children
|
||||||
var childAddresses = new HashSet<string>();
|
var childAddresses = new HashSet<string>();
|
||||||
if (!Instance.TryGet(parentIndexId, out var groupItem) || groupItem.ChildItems.IsNullOrEmpty())
|
if (!Instance.TryGet(indexId, out var groupItem) || groupItem.ChildItems.IsNullOrEmpty())
|
||||||
return childAddresses;
|
return childAddresses;
|
||||||
|
|
||||||
var childIds = Utils.String2List(groupItem.ChildItems);
|
var childIds = Utils.String2List(groupItem.ChildItems);
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace ServiceLib.Models;
|
||||||
public class ProfileGroupItem
|
public class ProfileGroupItem
|
||||||
{
|
{
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
public string ParentIndexId { get; set; }
|
public string IndexId { get; set; }
|
||||||
|
|
||||||
public string ChildItems { get; set; }
|
public string ChildItems { get; set; }
|
||||||
|
|
||||||
|
|
|
@ -218,7 +218,7 @@ public class AddGroupServerViewModel : MyReactiveObject
|
||||||
_ => EMultipleLoad.LeastPing,
|
_ => EMultipleLoad.LeastPing,
|
||||||
};
|
};
|
||||||
|
|
||||||
var hasCycle = ProfileGroupItemManager.HasCycle(profileGroup.ParentIndexId);
|
var hasCycle = ProfileGroupItemManager.HasCycle(profileGroup.IndexId);
|
||||||
if (hasCycle)
|
if (hasCycle)
|
||||||
{
|
{
|
||||||
NoticeManager.Instance.Enqueue(string.Format(ResUI.GroupSelfReference, remarks));
|
NoticeManager.Instance.Enqueue(string.Format(ResUI.GroupSelfReference, remarks));
|
||||||
|
|
Loading…
Reference in a new issue