mirror of https://github.com/2dust/v2rayN
treat index in menuRemoveDuplicateServer
parent
9549d17b03
commit
56559e6509
|
@ -627,12 +627,22 @@ namespace v2rayN.Forms
|
|||
|
||||
private void menuRemoveDuplicateServer_Click(object sender, EventArgs e)
|
||||
{
|
||||
VmessItem activeVm = null;
|
||||
if (config.index >= 0) {
|
||||
activeVm = config.vmess[config.index];
|
||||
}
|
||||
Utils.DedupServerList(config.vmess, out List<VmessItem> servers, config.keepOlderDedupl);
|
||||
int oldCount = config.vmess.Count;
|
||||
int newCount = servers.Count;
|
||||
if (servers != null)
|
||||
{
|
||||
config.vmess = servers;
|
||||
|
||||
if (activeVm != null)
|
||||
{
|
||||
int index = Utils.ServerVmIndexof(config.vmess, activeVm);
|
||||
if (index >= 0) config.index = index; // restore to the correct value
|
||||
}
|
||||
}
|
||||
//刷新
|
||||
RefreshServers();
|
||||
|
|
|
@ -318,6 +318,10 @@ namespace v2rayN
|
|||
return $"{string.Format("{0:f1}", result)} {unit}";
|
||||
}
|
||||
|
||||
public static int ServerVmIndexof(List<Mode.VmessItem> source, Mode.VmessItem findIt)
|
||||
{
|
||||
return source.IndexOf(findIt);
|
||||
}
|
||||
public static void DedupServerList(List<Mode.VmessItem> source, out List<Mode.VmessItem> result, bool keepOlder)
|
||||
{
|
||||
List<Mode.VmessItem> list = new List<Mode.VmessItem>();
|
||||
|
|
Loading…
Reference in New Issue