Optimize RemoveInvalidServerResult
Some checks are pending
release Linux / build (Release) (push) Waiting to run
release macOS / build (Release) (push) Waiting to run
release Windows desktop (Avalonia UI) / build (Release) (push) Waiting to run
release Windows / build (Release) (push) Waiting to run

This commit is contained in:
2dust 2025-02-17 20:00:28 +08:00
parent 317a5da120
commit deafd73306
2 changed files with 12 additions and 15 deletions

View file

@ -294,7 +294,7 @@ namespace ServiceLib.Handler
/// <param name="config"></param>
/// <param name="indexes"></param>
/// <returns></returns>
public static async Task<int> RemoveServer(Config config, List<ProfileItem> indexes)
public static async Task<int> RemoveServers(Config config, List<ProfileItem> indexes)
{
var subid = "TempRemoveSubId";
foreach (var item in indexes)
@ -303,7 +303,7 @@ namespace ServiceLib.Handler
}
await SQLiteHelper.Instance.UpdateAllAsync(indexes);
await RemoveServerViaSubid(config, subid, false);
await RemoveServersViaSubid(config, subid, false);
return 0;
}
@ -886,7 +886,7 @@ namespace ServiceLib.Handler
lstRemove.Add(item);
}
}
await RemoveServer(config, lstRemove);
await RemoveServers(config, lstRemove);
return new Tuple<int, int>(lstProfile.Count, lstKeep.Count);
}
@ -1062,12 +1062,9 @@ namespace ServiceLib.Handler
var lstProfile = (from t in lstModel
join t2 in lstProfileExs on t.IndexId equals t2.IndexId
where t2.Delay == -1
select t.IndexId).ToList();
select t).ToList();
foreach (var item in lstProfile)
{
await RemoveProfileItem(config, item);
}
await RemoveServers(config, JsonUtils.Deserialize<List<ProfileItem>>(JsonUtils.Serialize(lstProfile)));
return lstProfile.Count;
}
@ -1094,7 +1091,7 @@ namespace ServiceLib.Handler
//remove sub items
if (isSub && Utils.IsNotEmpty(subid))
{
await RemoveServerViaSubid(config, subid, isSub);
await RemoveServersViaSubid(config, subid, isSub);
subFilter = (await AppHandler.Instance.GetSubItem(subid))?.Filter ?? "";
}
@ -1188,7 +1185,7 @@ namespace ServiceLib.Handler
{
if (isSub && Utils.IsNotEmpty(subid))
{
await RemoveServerViaSubid(config, subid, isSub);
await RemoveServersViaSubid(config, subid, isSub);
}
int count = 0;
foreach (var it in lstProfiles)
@ -1244,7 +1241,7 @@ namespace ServiceLib.Handler
if (isSub && Utils.IsNotEmpty(subid))
{
await RemoveServerViaSubid(config, subid, isSub);
await RemoveServersViaSubid(config, subid, isSub);
}
profileItem.Subid = subid;
@ -1269,7 +1266,7 @@ namespace ServiceLib.Handler
if (isSub && Utils.IsNotEmpty(subid))
{
await RemoveServerViaSubid(config, subid, isSub);
await RemoveServersViaSubid(config, subid, isSub);
}
var lstSsServer = ShadowsocksFmt.ResolveSip008(strData);
@ -1456,7 +1453,7 @@ namespace ServiceLib.Handler
/// <param name="config"></param>
/// <param name="subid"></param>
/// <returns></returns>
public static async Task<int> RemoveServerViaSubid(Config config, string subid, bool isSub)
public static async Task<int> RemoveServersViaSubid(Config config, string subid, bool isSub)
{
if (Utils.IsNullOrEmpty(subid))
{
@ -1487,7 +1484,7 @@ namespace ServiceLib.Handler
return 0;
}
await SQLiteHelper.Instance.DeleteAsync(item);
await RemoveServerViaSubid(config, id, false);
await RemoveServersViaSubid(config, id, false);
return 0;
}

View file

@ -520,7 +520,7 @@ namespace ServiceLib.ViewModels
}
var exists = lstSelecteds.Exists(t => t.IndexId == _config.IndexId);
await ConfigHandler.RemoveServer(_config, lstSelecteds);
await ConfigHandler.RemoveServers(_config, lstSelecteds);
NoticeHandler.Instance.Enqueue(ResUI.OperationSuccess);
if (lstSelecteds.Count == _profileItems.Count)
{