Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions changelog/unreleased/4922
Comment thread
joragua marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Bugfix: Spaces search filter for multi-personal accounts (Kiteworks accounts)

All matching personal spaces have been included in the spaces search filter for multi-personal accounts.

https://github.com/owncloud/android/issues/4674
https://github.com/owncloud/android/pull/4922
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,7 @@ class SpacesListFragment :
collectLatestLifecycleFlow(spacesListViewModel.spacesList) { uiState ->
var spacesToListFiltered: List<OCSpace>
if (uiState.searchFilter != "") {
spacesToListFiltered =
uiState.spaces.filter { it.name.lowercase().contains(uiState.searchFilter.lowercase()) && !it.isPersonal &&
shouldShowDisabledSpace(it) }
val personalSpace = uiState.spaces.find { it.isPersonal }
personalSpace?.let {
spacesToListFiltered = spacesToListFiltered.toMutableList().apply {
add(0, personalSpace)
}
}
spacesToListFiltered = uiState.spaces.filterSpaces(uiState.searchFilter, isMultiPersonal)
showOrHideEmptyView(spacesToListFiltered)
Comment thread
joragua marked this conversation as resolved.
spacesListAdapter.setData(spacesToListFiltered, isMultiPersonal)
} else {
Expand Down Expand Up @@ -484,6 +476,17 @@ class SpacesListFragment :
binding.fileOptionsBottomSheetLayout.addView(fileOptionItemView)
}

private fun List<OCSpace>.filterSpaces(query: String, multiPersonal: Boolean): List<OCSpace> {
val queryLowercase = query.lowercase()
val spacesMatchingName = filter { it.name.lowercase().contains(queryLowercase) }
val matchingSpaces = spacesMatchingName.filter {
(multiPersonal || !it.isPersonal) && shouldShowDisabledSpace(it)
}
if (multiPersonal) return matchingSpaces
val personalSpace = find { it.isPersonal } ?: return matchingSpaces
return listOf(personalSpace) + matchingSpaces
}

private fun shouldShowDisabledSpace(space: OCSpace): Boolean = !space.isDisabled || spacesListViewModel.showDisabledSpaces

private fun isPickerMode(): Boolean = requireArguments().getBoolean(BUNDLE_IS_PICKER_MODE, false)
Expand Down