remove old servers when update subscription (#5424)

* remove old servers when update subscription

* Supplementary Submission: Multiple Configuration Scenarios
This commit is contained in:
owo
2026-03-29 17:47:37 +08:00
committed by GitHub
parent d6d5753283
commit e6c8307b96
@@ -372,6 +372,7 @@ object AngConfigManager {
JsonUtil.fromJson(server, Array<Any>::class.java) ?: arrayOf()
if (serverList.isNotEmpty()) {
MmkvManager.removeServerViaSubid(subid)
var count = 0
for (srv in serverList.reversed()) {
val config = CustomFmt.parse(JsonUtil.toJson(srv)) ?: continue
@@ -392,6 +393,7 @@ object AngConfigManager {
val config = CustomFmt.parse(server) ?: return 0
config.subscriptionId = subid
config.description = generateDescription(config)
MmkvManager.removeServerViaSubid(subid)
val key = MmkvManager.encodeServerConfig("", config)
MmkvManager.encodeServerRaw(key, server)
return 1
@@ -403,6 +405,7 @@ object AngConfigManager {
try {
val config = WireguardFmt.parseWireguardConfFile(server) ?: return R.string.toast_incorrect_protocol
config.description = generateDescription(config)
MmkvManager.removeServerViaSubid(subid)
val key = MmkvManager.encodeServerConfig("", config)
MmkvManager.encodeServerRaw(key, server)
return 1