Merge pull request #2130 from pouriaksrvi/master

[New Feature] UX enhancement - Reversed the order of server list
This commit is contained in:
2dust
2023-04-06 08:28:54 +08:00
committed by GitHub
3 changed files with 4 additions and 3 deletions
@@ -756,6 +756,7 @@ object AngConfigManager {
var count = 0
servers.lines()
.reversed()
.forEach {
val resId = importConfig(it, subid, removedSelectedServer)
if (resId == 0) {
@@ -46,7 +46,7 @@ object MmkvManager {
serverStorage?.encode(key, Gson().toJson(config))
val serverList = decodeServerList()
if (!serverList.contains(key)) {
serverList.add(key)
serverList.add(0, key)
mainStorage?.encode(KEY_ANG_CONFIGS, Gson().toJson(serverList))
if (mainStorage?.decodeString(KEY_SELECTED_SERVER).isNullOrBlank()) {
mainStorage?.encode(KEY_SELECTED_SERVER, key)
@@ -74,8 +74,8 @@ class MainViewModel(application: Application) : AndroidViewModel(application) {
config.fullConfig = Gson().fromJson(server, V2rayConfig::class.java)
val key = MmkvManager.encodeServerConfig("", config)
serverRawStorage?.encode(key, server)
serverList.add(key)
serversCache.add(ServersCache(key,config))
serverList.add(0, key)
serversCache.add(0, ServersCache(key,config))
}
fun swapServer(fromPosition: Int, toPosition: Int) {