diff --git a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatCombo.kt b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatCombo.kt index 093f8a971b..c84ac29857 100644 --- a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatCombo.kt +++ b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatCombo.kt @@ -19,9 +19,9 @@ class ConfigureEventCatCombo( repository.catCombo().apply { val categories = getCategories(this?.categories()) val categoryOptions = getCategoryOptions() + updateSelectedOptions(categoryOption, categories, categoryOptions) val catComboUid = getCatComboUid(this?.uid() ?: "", this?.isDefault ?: false) val catComboDisplayName = getCatComboDisplayName(this?.uid() ?: "") - updateSelectedOptions(categoryOption, categories, categoryOptions) return flowOf( EventCatCombo( diff --git a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/providers/InputFieldsProvider.kt b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/providers/InputFieldsProvider.kt index 69c297b4a4..8c668b5044 100644 --- a/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/providers/InputFieldsProvider.kt +++ b/app/src/main/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/providers/InputFieldsProvider.kt @@ -213,7 +213,7 @@ fun ProvideCategorySelector( modifier: Modifier = Modifier, eventCatComboUiModel: EventCatComboUiModel, ) { - var selectedItem by remember { + var selectedItem by remember(eventCatComboUiModel.eventCatCombo.selectedCategoryOptions) { mutableStateOf( eventCatComboUiModel.eventCatCombo.selectedCategoryOptions[eventCatComboUiModel.category.uid]?.displayName() ?: eventCatComboUiModel.eventCatCombo.categoryOptions?.get(eventCatComboUiModel.category.uid)?.displayName(), diff --git a/app/src/test/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatComboTest.kt b/app/src/test/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatComboTest.kt index 2a6d30821e..087ab9b827 100644 --- a/app/src/test/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatComboTest.kt +++ b/app/src/test/java/org/dhis2/usescases/eventsWithoutRegistration/eventDetails/domain/ConfigureEventCatComboTest.kt @@ -8,6 +8,7 @@ import org.hisp.dhis.android.core.category.CategoryCombo import org.hisp.dhis.android.core.category.CategoryOption import org.hisp.dhis.android.core.category.CategoryOptionCombo import org.hisp.dhis.android.core.event.Event +import org.junit.Assert.assertEquals import org.junit.Assert.assertFalse import org.junit.Assert.assertTrue import org.junit.Before @@ -70,12 +71,17 @@ class ConfigureEventCatComboTest { whenever( repository.getCatOption(CATEGORY_OPTION_UID), ) doReturn categoryOption + whenever( + repository.getCategoryOptionCombo(CATEGORY_COMBO_UID, listOf(CATEGORY_OPTION_UID)), + ) doReturn CATEGORY_OPTION_COMBO_UID // When catCombo is invoked val eventCatCombo = configureEventCatCombo.invoke(selectedCategoryOption).first() // Then should be completed assertTrue(eventCatCombo.isCompleted) + // And the EventCatCombo uid should be set + assertEquals(eventCatCombo.uid, CATEGORY_OPTION_COMBO_UID) } @Test diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ff295f775f..7bbf3ca5b6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,8 +2,8 @@ ndk = "21.4.7075529" sdk = "34" minSdk = "21" -vCode = "130" -vName = "2.9.1" +vCode = "131" +vName = "2.9.1.1" kotlinCompilerExtensionVersion = "1.5.6" gradle = "8.2.0" kotlin = '1.9.21'