its better, no?

This commit is contained in:
Mylloon 2024-01-04 14:56:11 +01:00
parent 3fed81982c
commit 4566efc7f7
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -11,15 +11,16 @@ import kotlinx.coroutines.launch
class ModifySetViewModel(application: Application) : AndroidViewModel(application) {
private val dao = (application as MemoApplication).database.memoDao()
private val initialId = -1 // invalid ID, mean that we don't have the ID yet
var setId = mutableStateOf(-1)
var setId = mutableStateOf(initialId)
var questions = dao.loadQuestions(setId.value)
var selection = mutableStateOf<Question?>(null)
var action = mutableStateOf(ActionModifySet.AUCUN)
fun updateQuestionList(setId: Int) {
viewModelScope.launch(Dispatchers.IO) {
questions = dao.loadQuestions(setId)
if (setId != initialId) {
viewModelScope.launch(Dispatchers.IO) { questions = dao.loadQuestions(setId) }
}
}