mirror of https://github.com/2dust/v2rayN
Fix delete duplicate server
parent
785a30e623
commit
9dc6ba182a
|
@ -800,16 +800,15 @@ namespace v2rayN.Handler
|
|||
return 0;
|
||||
}
|
||||
|
||||
public static int DedupServerList(ref Config config, ref List<ProfileItem> lstProfile)
|
||||
public static Tuple<int, int> DedupServerList(Config config, string subId)
|
||||
{
|
||||
List<ProfileItem> source = lstProfile;
|
||||
bool keepOlder = config.guiItem.keepOlderDedupl;
|
||||
var lstProfile = LazyConfig.Instance.ProfileItems(subId);
|
||||
|
||||
List<ProfileItem> lstKeep = new();
|
||||
List<ProfileItem> lstRemove = new();
|
||||
if (!keepOlder) source.Reverse(); // Remove the early items first
|
||||
if (config.guiItem.keepOlderDedupl) lstProfile.Reverse();
|
||||
|
||||
foreach (ProfileItem item in source)
|
||||
foreach (ProfileItem item in lstProfile)
|
||||
{
|
||||
if (!lstKeep.Exists(i => CompareProfileItem(i, item, false)))
|
||||
{
|
||||
|
@ -822,7 +821,7 @@ namespace v2rayN.Handler
|
|||
}
|
||||
RemoveServer(config, lstRemove);
|
||||
|
||||
return lstKeep.Count;
|
||||
return new Tuple<int, int>(lstProfile.Count, lstKeep.Count);
|
||||
}
|
||||
|
||||
public static int AddServerCommon(ref Config config, ProfileItem profileItem, bool toFile = true)
|
||||
|
|
|
@ -971,11 +971,10 @@ namespace v2rayN.ViewModels
|
|||
|
||||
private void RemoveDuplicateServer()
|
||||
{
|
||||
int oldCount = _lstProfile.Count;
|
||||
int newCount = ConfigHandler.DedupServerList(ref _config, ref _lstProfile);
|
||||
var tuple = ConfigHandler.DedupServerList(_config, _subId);
|
||||
RefreshServers();
|
||||
Reload();
|
||||
_noticeHandler?.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, oldCount, newCount));
|
||||
_noticeHandler?.Enqueue(string.Format(ResUI.RemoveDuplicateServerResult, tuple.Item1, tuple.Item2));
|
||||
}
|
||||
private void CopyServer()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue