Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: [ANDROAPP-6277] Working lists not filtering search results
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo <[email protected]>
Balcan committed Jul 2, 2024
1 parent 385eadc commit bf5a58c
Showing 1 changed file with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -44,30 +44,27 @@ class SearchRepositoryImplKt(
searchParametersModel: SearchParametersModel,
isOnline: Boolean,
): TrackedEntitySearchCollectionRepository {
var allowCache = false

if (searchParametersModel != searchRepositoryJava.savedSearchParameters || !FilterManager.getInstance()
.sameFilters(searchRepositoryJava.savedFilters)
) {
trackedEntityInstanceQuery =
searchRepositoryJava.getFilteredRepository(searchParametersModel)
} else {
trackedEntityInstanceQuery =
searchRepositoryJava.getFilteredRepository(searchParametersModel)
allowCache = true
}

if (searchRepositoryJava.fetchedTeiUIDs.isNotEmpty() && searchParametersModel.selectedProgram == null) {
trackedEntityInstanceQuery =
trackedEntityInstanceQuery.excludeUids().`in`(searchRepositoryJava.fetchedTeiUIDs.toList())
val allowCache = !(
searchParametersModel != searchRepositoryJava.savedSearchParameters ||
!FilterManager.getInstance().sameFilters(searchRepositoryJava.savedFilters)
)

if (
searchRepositoryJava.fetchedTeiUIDs.isNotEmpty() &&
searchParametersModel.selectedProgram == null
) {
trackedEntityInstanceQuery = trackedEntityInstanceQuery.excludeUids()
.`in`(searchRepositoryJava.fetchedTeiUIDs.toList())
}

val pagerFlow = if (isOnline && FilterManager.getInstance().stateFilters.isEmpty()) {
return if (isOnline && FilterManager.getInstance().stateFilters.isEmpty()) {
trackedEntityInstanceQuery.allowOnlineCache().eq(allowCache).offlineFirst()
} else {
trackedEntityInstanceQuery.allowOnlineCache().eq(allowCache).offlineOnly()
}

return pagerFlow
}

override suspend fun searchParameters(

0 comments on commit bf5a58c

Please sign in to comment.