[fix] Can't hot reload server config in abyss mode.

This commit is contained in:
acite
2025-09-17 00:09:30 +08:00
parent 2260f26d9a
commit c402e18206
2 changed files with 7 additions and 10 deletions

View File

@@ -116,7 +116,7 @@ fun MeScreen(meScreenViewModel: MeScreenViewModel = androidx.hilt.lifecycle.view
// Save Button
Button(
onClick = {
meScreenViewModel.updateAccount(username, privateKey, context)
meScreenViewModel.updateAccount(username, privateKey)
},
modifier = Modifier.fillMaxWidth(),
enabled = privateKey != "******"
@@ -198,7 +198,7 @@ fun MeScreen(meScreenViewModel: MeScreenViewModel = androidx.hilt.lifecycle.view
Row{
Button(
onClick = {
meScreenViewModel.updateServer(url, cert, context)
meScreenViewModel.updateServer(url, cert)
},
modifier = Modifier.weight(0.5f).padding(8.dp)
) {

View File

@@ -86,7 +86,7 @@ class MeScreenViewModel @Inject constructor(
}
}
fun updateServer(u: String, c: String, context: Context)
fun updateServer(u: String, c: String)
{
viewModelScope.launch {
settingsDataStoreManager.saveUrl(u)
@@ -101,26 +101,23 @@ class MeScreenViewModel @Inject constructor(
try {
val usedUrl = ApiClient.apply(context, u, if(uss.first()) c else "")
(context as AetherApp).abyssService?.proxy?.config(ApiClient.getBase().toUri().host!!, 4096)
context.abyssService?.downloader?.init()
mediaManager.token = AuthManager.fetchToken(
us,
p
)!!
Global.loggedIn = true
withContext(Dispatchers.IO)
{
(context as AetherApp).abyssService?.proxy?.config(ApiClient.getBase().toUri().host!!, 4096)
context.abyssService?.downloader?.init()
}
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()
Toast.makeText(context, "${e.message}", Toast.LENGTH_SHORT).show()
}
}
}
fun updateAccount(u: String, p: String, context: Context) {
fun updateAccount(u: String, p: String) {
viewModelScope.launch {
settingsDataStoreManager.saveUserName(u)
settingsDataStoreManager.savePrivateKey(p)