mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 15:15:34 +03:00
BIT-2131: Display folders when filtering by org in vault (#1170)
This commit is contained in:
parent
9144bae079
commit
25ceaf8c0b
4 changed files with 27 additions and 10 deletions
|
@ -672,9 +672,7 @@ class VaultItemListingViewModel @Inject constructor(
|
|||
itemListingType = currentState
|
||||
.itemListingType
|
||||
.updateWithAdditionalDataIfNecessary(
|
||||
folderList = vaultData
|
||||
.folderViewList
|
||||
.toFilteredList(state.vaultFilterType),
|
||||
folderList = vaultData.folderViewList,
|
||||
collectionList = vaultData
|
||||
.collectionViewList
|
||||
.toFilteredList(state.vaultFilterType),
|
||||
|
|
|
@ -209,7 +209,9 @@ fun List<SendView>.toViewState(
|
|||
)
|
||||
}
|
||||
|
||||
/** * Updates a [VaultItemListingState.ItemListingType] with the given data if necessary. */
|
||||
/**
|
||||
* Updates a [VaultItemListingState.ItemListingType] with the given data if necessary.
|
||||
*/
|
||||
fun VaultItemListingState.ItemListingType.updateWithAdditionalDataIfNecessary(
|
||||
folderList: List<FolderView>,
|
||||
collectionList: List<CollectionView>,
|
||||
|
|
|
@ -46,7 +46,12 @@ fun VaultData.toViewState(
|
|||
val filteredCipherViewList = filteredCipherViewListWithDeletedItems
|
||||
.filter { it.deletedDate == null }
|
||||
|
||||
val filteredFolderViewList = folderViewList.toFilteredList(vaultFilterType).getFilteredFolders()
|
||||
val filteredFolderViewList = folderViewList
|
||||
.toFilteredList(
|
||||
cipherList = filteredCipherViewList,
|
||||
vaultFilterType = vaultFilterType,
|
||||
)
|
||||
.getFilteredFolders()
|
||||
|
||||
val filteredCollectionViewList = collectionViewList
|
||||
.toFilteredList(vaultFilterType)
|
||||
|
@ -257,17 +262,20 @@ fun List<CipherView>.toFilteredList(
|
|||
*/
|
||||
@JvmName("toFilteredFolderList")
|
||||
fun List<FolderView>.toFilteredList(
|
||||
cipherList: List<CipherView>,
|
||||
vaultFilterType: VaultFilterType,
|
||||
): List<FolderView> =
|
||||
this
|
||||
.filter {
|
||||
.filter { folder ->
|
||||
when (vaultFilterType) {
|
||||
// Folders are only included when including the user's personal data.
|
||||
VaultFilterType.AllVaults,
|
||||
VaultFilterType.MyVault,
|
||||
-> true
|
||||
|
||||
is VaultFilterType.OrganizationVault -> false
|
||||
// Only include folders containing an item associated with this organization.
|
||||
is VaultFilterType.OrganizationVault -> {
|
||||
cipherList.any { it.folderId == folder.id }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -152,7 +152,10 @@ class VaultDataExtensionsTest {
|
|||
createMockCollectionView(number = 1),
|
||||
createMockCollectionView(number = 2),
|
||||
),
|
||||
folderViewList = listOf(createMockFolderView(number = 1)),
|
||||
folderViewList = listOf(
|
||||
createMockFolderView(number = 1),
|
||||
createMockFolderView(number = 3),
|
||||
),
|
||||
sendViewList = listOf(createMockSendView(number = 1)),
|
||||
)
|
||||
|
||||
|
@ -173,7 +176,13 @@ class VaultDataExtensionsTest {
|
|||
identityItemsCount = 0,
|
||||
secureNoteItemsCount = 0,
|
||||
favoriteItems = listOf(),
|
||||
folderItems = listOf(),
|
||||
folderItems = listOf(
|
||||
VaultState.ViewState.FolderItem(
|
||||
id = "mockId-1",
|
||||
name = "mockName-1".asText(),
|
||||
itemCount = 1,
|
||||
),
|
||||
),
|
||||
collectionItems = listOf(
|
||||
VaultState.ViewState.CollectionItem(
|
||||
id = "mockId-1",
|
||||
|
|
Loading…
Reference in a new issue