Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map search bug fixes #3516

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -1070,14 +1070,20 @@
if (currentPage != null && pageSize != null) {
val fromIndex = currentPage * pageSize
val toIndex = (currentPage + 1) * pageSize
with(searchResults.subList(fromIndex, min(toIndex, searchResults.size))) {
mapResourceToRepositoryResourceData(
relatedResourcesConfig = relatedResourcesConfig,
configComputedRuleValues = configComputedRuleValues,
secondaryResourceConfigs = secondaryResourceConfigs,
filterActiveResources = filterActiveResources,
baseResourceConfig = baseResourceConfig,
)
val maxSublistIndex = min(toIndex, searchResults.size)

Check warning on line 1073 in android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt

View check run for this annotation

Codecov / codecov/patch

android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt#L1073

Added line #L1073 was not covered by tests

if (fromIndex < maxSublistIndex) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can add an edge case unit test for when we only have one item in the searchResults (if there's none already)

with(searchResults.subList(fromIndex, maxSublistIndex)) {
mapResourceToRepositoryResourceData(
relatedResourcesConfig = relatedResourcesConfig,
configComputedRuleValues = configComputedRuleValues,
secondaryResourceConfigs = secondaryResourceConfigs,
filterActiveResources = filterActiveResources,
baseResourceConfig = baseResourceConfig,

Check warning on line 1082 in android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt

View check run for this annotation

Codecov / codecov/patch

android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt#L1076-L1082

Added lines #L1076 - L1082 were not covered by tests
)
}
} else {
emptyList()

Check warning on line 1086 in android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt

View check run for this annotation

Codecov / codecov/patch

android/engine/src/main/java/org/smartregister/fhircore/engine/data/local/DefaultRepository.kt#L1086

Added line #L1086 was not covered by tests
}
} else {
searchResults.mapResourceToRepositoryResourceData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,7 @@
when {
!searchQuery.isBlank() -> {
IconButton(
onClick = {
onSearchTextChanged(SearchQuery.emptyText, performSearchOnValueChanged)
},
onClick = { onSearchTextChanged(SearchQuery.emptyText, true) },

Check warning on line 240 in android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt

View check run for this annotation

Codecov / codecov/patch

android/quest/src/main/java/org/smartregister/fhircore/quest/ui/main/components/TopScreenSection.kt#L240

Added line #L240 was not covered by tests
Copy link
Contributor

@ndegwamartin ndegwamartin Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might it be better to fix it by passing the value true from the line here?

Or even consider removing it entirely since the value true is the default.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ndegwamartin We want to automatically disable search on text change for the map but enable it for the registers. This disables it for the map.

We however want to refresh the map view every time we clear data for both the register and map views hence the true. If we use performSearchOnValueChanged this is updated to false on the link you shared earlier.

modifier = modifier.testTag(TRAILING_ICON_BUTTON_TEST_TAG),
) {
Icon(
Expand Down
Loading