[feat] Smart Server Selection

This commit is contained in:
acite
2025-09-07 23:04:15 +08:00
parent aacd226260
commit f6583ffcf1
3 changed files with 40 additions and 10 deletions

View File

@@ -1,6 +1,7 @@
package com.acitelight.aether.viewModel
import android.app.Application
import android.widget.Toast
import androidx.compose.runtime.Composable
import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.ViewModel
@@ -86,7 +87,7 @@ class HomeScreenViewModel(application: Application) : AndroidViewModel(applicati
if(u=="" || p=="" || ur=="" || c=="") return@launch
try{
ApiClient.apply(ur, c)
val usedUrl = ApiClient.apply(ur, c)
if (MediaManager.token == "null")
MediaManager.token = AuthManager.fetchToken(

View File

@@ -76,14 +76,14 @@ class MeScreenViewModel(application: Application) : AndroidViewModel(application
if (u == "" || c == "" || p == "" || us == "") return@launch
try {
ApiClient.apply(u, c)
val usedUrl = ApiClient.apply(u, c)
MediaManager.token = AuthManager.fetchToken(
us,
p
)!!
Global.loggedIn = true
Toast.makeText(context, "Server Updated", Toast.LENGTH_SHORT).show()
Toast.makeText(context, "Server Updated, Used Url: $usedUrl", Toast.LENGTH_SHORT).show()
} catch (e: Exception) {
print(e.message)
Toast.makeText(context, "Invalid Account or Server Information", Toast.LENGTH_SHORT).show()