add missing methods
This commit is contained in:
parent
ed1a870e1b
commit
439b8aa4f0
1 changed files with 32 additions and 0 deletions
|
@ -113,4 +113,36 @@ 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
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue