Compare commits
No commits in common. "3a8ae37c09870189fc41784a207d20cc4a01bc88" and "3ddbe78fe802ac661ee43d20f3efbd95900d447d" have entirely different histories.
3a8ae37c09
...
3ddbe78fe8
3 changed files with 8 additions and 35 deletions
|
@ -52,7 +52,6 @@ class DashboardActivity : ComponentActivity() {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||||
dashboardViewModel.refreshError.collect {
|
dashboardViewModel.refreshError.collect {
|
||||||
if (it != null)
|
|
||||||
Toast.makeText(baseContext, it, Toast.LENGTH_SHORT).show()
|
Toast.makeText(baseContext, it, Toast.LENGTH_SHORT).show()
|
||||||
} // TODO any better way?
|
} // TODO any better way?
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,36 +113,4 @@ class DashboardViewModel(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleInstance(instance: RentedInstance) {
|
|
||||||
val deferred =
|
|
||||||
if (instance.status == "running") {
|
|
||||||
vastApi.startInstance(instance.rentalId)
|
|
||||||
} else {
|
|
||||||
vastApi.stopInstance(instance.rentalId)
|
|
||||||
}
|
|
||||||
|
|
||||||
viewModelScope.launch {
|
|
||||||
try {
|
|
||||||
deferred.await()
|
|
||||||
refresh()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
_refreshError.value = e.message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun deleteInstance(instance: RentedInstance) {
|
|
||||||
val deferred = vastApi.deleteInstance(instance.rentalId)
|
|
||||||
|
|
||||||
viewModelScope.launch {
|
|
||||||
try {
|
|
||||||
deferred.await()
|
|
||||||
refresh()
|
|
||||||
} catch (e: Exception) {
|
|
||||||
_refreshError.value = e.message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} // TODO once again these methods share some code and more probably will so why not move the shared stuff
|
|
||||||
// OR not refresh but refresh only instances or even better don't refresh instances but delete or edit that one
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -108,11 +108,17 @@ class LoginActivity : ComponentActivity() {
|
||||||
verticalArrangement = Arrangement.Center,
|
verticalArrangement = Arrangement.Center,
|
||||||
horizontalAlignment = Alignment.CenterHorizontally
|
horizontalAlignment = Alignment.CenterHorizontally
|
||||||
) {
|
) {
|
||||||
|
val loading by loginViewModel.fullscreenLoading.collectAsState()
|
||||||
|
|
||||||
|
if (loading) {
|
||||||
|
CircularProgressIndicator()
|
||||||
|
} else {
|
||||||
LoginApp(loginViewModel)
|
LoginApp(loginViewModel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue