[fix] Prevent mixed video lists when switching tabs quickly& Not confirming server information when updating accounts

This commit is contained in:
acite
2025-08-27 00:43:02 +08:00
parent 3ed53ee593
commit fc76e6995f
3 changed files with 11 additions and 5 deletions

View File

@@ -106,7 +106,8 @@ fun MeScreen(meScreenViewModel: MeScreenViewModel = viewModel()) {
onClick = { onClick = {
meScreenViewModel.updateAccount(username, privateKey, context) meScreenViewModel.updateAccount(username, privateKey, context)
}, },
modifier = Modifier.fillMaxWidth() modifier = Modifier.fillMaxWidth(),
enabled = privateKey != "******"
) { ) {
Text("Save") Text("Save")
} }

View File

@@ -73,7 +73,7 @@ class MeScreenViewModel(application: Application) : AndroidViewModel(application
val c = certFlow.first() val c = certFlow.first()
val p = privateKeyFlow.first() val p = privateKeyFlow.first()
if (u == "" || c == "" || p == "") return@launch if (u == "" || c == "" || p == "" || us == "") return@launch
try { try {
ApiClient.apply(u, c) ApiClient.apply(u, c)
@@ -105,7 +105,10 @@ class MeScreenViewModel(application: Application) : AndroidViewModel(application
val u = userNameFlow.first() val u = userNameFlow.first()
val p = privateKeyFlow.first() val p = privateKeyFlow.first()
if (u == "" || p == "") return@launch val ur = urlFlow.first()
val c = certFlow.first()
if (u == "" || p == "" || ur == "" || c == "") return@launch
try { try {
MediaManager.token = AuthManager.fetchToken( MediaManager.token = AuthManager.fetchToken(

View File

@@ -63,8 +63,9 @@ class VideoScreenViewModel(application: Application) : AndroidViewModel(applicat
suspend fun init() { suspend fun init() {
_klasses.value = MediaManager.listVideoKlasses() _klasses.value = MediaManager.listVideoKlasses()
MediaManager.listVideos(_klasses.value.first()){ MediaManager.listVideos(_klasses.value.first()){
v -> videos.add(videos.size, v) v -> if(0 == tabIndex.value && !videos.contains(v)) videos.add(videos.size, v)
} }
} }
@@ -73,10 +74,11 @@ class VideoScreenViewModel(application: Application) : AndroidViewModel(applicat
viewModelScope.launch() viewModelScope.launch()
{ {
_tabIndex.intValue = index; _tabIndex.intValue = index;
videos.clear() videos.clear()
MediaManager.listVideos(_klasses.value[index]) MediaManager.listVideos(_klasses.value[index])
{ {
v -> videos.add(videos.size, v) v -> if(index == tabIndex.value) videos.add(videos.size, v)
} }
} }
} }