@@ -30,7 +30,6 @@ import androidx.compose.material.icons.Icons
3030import androidx.compose.material.icons.rounded.ArrowBackIos
3131import androidx.compose.material.icons.rounded.ArrowForwardIos
3232import androidx.compose.runtime.Composable
33- import androidx.compose.runtime.LaunchedEffect
3433import androidx.compose.runtime.getValue
3534import androidx.compose.runtime.mutableStateOf
3635import androidx.compose.runtime.remember
@@ -44,11 +43,11 @@ import androidx.compose.ui.unit.dp
4443import cafe.adriel.voyager.core.screen.Screen
4544import cz.frantisekmasa.wfrp_master.common.Str
4645import cz.frantisekmasa.wfrp_master.common.character.CharacterDetailScreen
47- import cz.frantisekmasa.wfrp_master.common.compendium.domain.Career
4846import cz.frantisekmasa.wfrp_master.common.core.auth.UserId
4947import cz.frantisekmasa.wfrp_master.common.core.domain.character.CharacterType
5048import cz.frantisekmasa.wfrp_master.common.core.domain.party.PartyId
5149import cz.frantisekmasa.wfrp_master.common.core.ui.buttons.BackButton
50+ import cz.frantisekmasa.wfrp_master.common.core.ui.flow.collectWithLifecycle
5251import cz.frantisekmasa.wfrp_master.common.core.ui.forms.FormData
5352import cz.frantisekmasa.wfrp_master.common.core.ui.navigation.LocalNavigationTransaction
5453import cz.frantisekmasa.wfrp_master.common.core.ui.primitives.FullScreenProgress
@@ -58,7 +57,6 @@ import cz.frantisekmasa.wfrp_master.common.core.ui.scaffolding.SubheadBar
5857import dev.icerock.moko.resources.compose.stringResource
5958import kotlinx.coroutines.Dispatchers
6059import kotlinx.coroutines.launch
61- import kotlinx.coroutines.withContext
6260
6361private enum class FormState {
6462 EDITED_BY_USER ,
@@ -90,15 +88,7 @@ private fun Screen.MainContainer(partyId: PartyId, type: CharacterType, userId:
9088 val screenModel: CharacterCreationScreenModel = rememberScreenModel(arg = partyId)
9189 val coroutineScope = rememberCoroutineScope()
9290
93- val (careers, setCareers) = rememberSaveable {
94- mutableStateOf<List <Career >? > (null )
95- }
96-
97- LaunchedEffect (Unit ) {
98- withContext(Dispatchers .IO ) {
99- setCareers(screenModel.getCareers())
100- }
101- }
91+ val careers = screenModel.careers.collectWithLifecycle(null ).value
10292
10393 if (careers == null ) {
10494 FullScreenProgress ()
0 commit comments