diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/util/CollectionViewExtensions.kt b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/util/CollectionViewExtensions.kt index 554b2bdb1..b75b186be 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/util/CollectionViewExtensions.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/vault/feature/util/CollectionViewExtensions.kt @@ -94,16 +94,17 @@ fun String.toCollectionDisplayName(list: List): String { * * Deletion is allowed when the item is in any collection that the user has "manage" permission for. */ -fun List?.hasDeletePermissionInAtLeastOneCollection(collectionIds: List?) = - this - ?.takeUnless { it.isEmpty() } - ?.any { +fun List?.hasDeletePermissionInAtLeastOneCollection( + collectionIds: List?, +): Boolean { + if (this.isNullOrEmpty() || collectionIds.isNullOrEmpty()) return true + return this + .any { collectionView -> collectionIds - ?.contains(it.id) - ?.let { isInCollection -> !isInCollection || it.manage } - ?: true + .contains(collectionView.id) + .let { isInCollection -> isInCollection && collectionView.manage } } - ?: true +} /** * Checks if the user has permission to assign an item to a collection.