Add Stories and Adventures section.

This commit is contained in:
Andres Gomez, Thomas (ITDV RL) 2024-06-17 13:03:13 +02:00
parent 4e103a2a37
commit 1a9104edec
37 changed files with 2381 additions and 13 deletions

View file

@ -6,6 +6,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.pixelized.rplexicon.data.repository.adventure.AdventureRepository
import com.pixelized.rplexicon.data.repository.character.ActionRepository
import com.pixelized.rplexicon.data.repository.character.AlterationRepository
import com.pixelized.rplexicon.data.repository.character.CharacterSheetRepository
@ -22,11 +23,13 @@ import com.pixelized.rplexicon.data.repository.lexicon.QuestRepository
import com.pixelized.rplexicon.ui.composable.error.FetchErrorUio
import com.pixelized.rplexicon.ui.composable.error.FetchErrorUio.Structure.Type
import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.async
import kotlinx.coroutines.awaitAll
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.launch
import kotlinx.coroutines.withContext
import javax.inject.Inject
@HiltViewModel
@ -44,6 +47,7 @@ class LauncherViewModel @Inject constructor(
descriptionRepository: DescriptionRepository,
inventoryRepository: InventoryRepository,
equipmentRepository: EquipmentRepository,
adventureRepository: AdventureRepository,
) : ViewModel() {
private val _error = MutableStateFlow<FetchErrorUio?>(null)
@ -53,7 +57,7 @@ class LauncherViewModel @Inject constructor(
private set
init {
viewModelScope.launch {
viewModelScope.launch(Dispatchers.Default) {
val order = async {
try {
categoryRepository.fetchCategoryOrder()
@ -164,7 +168,9 @@ class LauncherViewModel @Inject constructor(
awaitAll(order, lexicon, location, quest)
awaitAll(description, inventory, equipment, alteration, action, objects, spell, skill)
isLoading = false
withContext(Dispatchers.Main) {
isLoading = false
}
}
}