Update AngConfigManager.kt

Added remark for single config subscription
Removed unnecessary code in multiple config subscription update
This commit is contained in:
Vahid Farid committed 2024-03-02 18:27:59 +03:30
1 parent 376882d975
commit 9142b9cfb4
1 file changed
+10 -13
@@ -1008,17 +1008,15 @@ object AngConfigManager {
if (serverList.isNotEmpty()) { if (serverList.isNotEmpty()) {
var count = 0 var count = 0
for (srv in serverList) { for (srv in serverList) {
if (srv.inbounds != null && srv.outbounds != null && srv.routing != null) { val config = ServerConfig.create(EConfigType.CUSTOM)
val config = ServerConfig.create(EConfigType.CUSTOM) config.remarks = srv.remarks
config.remarks = srv.remarks ?: ("%04d-".format(count + 1) + System.currentTimeMillis()
?: "%04d-".format(count + 1) + System.currentTimeMillis() .toString())
.toString() config.subscriptionId = subid
config.subscriptionId = subid config.fullConfig = srv
config.fullConfig = srv val key = MmkvManager.encodeServerConfig("", config)
val key = MmkvManager.encodeServerConfig("", config) serverRawStorage?.encode(key, gson.toJson(srv))
serverRawStorage?.encode(key, gson.toJson(srv)) count += 1
count += 1
}
} }
return count return count
} }
@@ -1030,8 +1028,7 @@ object AngConfigManager {
val config = ServerConfig.create(EConfigType.CUSTOM) val config = ServerConfig.create(EConfigType.CUSTOM)
config.subscriptionId = subid config.subscriptionId = subid
config.fullConfig = Gson().fromJson(server, V2rayConfig::class.java) config.fullConfig = Gson().fromJson(server, V2rayConfig::class.java)
config.remarks = System.currentTimeMillis().toString() config.remarks = config.fullConfig?.remarks ?: System.currentTimeMillis().toString()
//config.remarks = config.fullConfig?.remarks ?: System.currentTimeMillis().toString()
val key = MmkvManager.encodeServerConfig("", config) val key = MmkvManager.encodeServerConfig("", config)
serverRawStorage?.encode(key, server) serverRawStorage?.encode(key, server)
return 1 return 1