mirror of
https://github.com/bitwarden/android.git
synced 2024-11-21 17:05:44 +03:00
[PM-10483] Fix collection manage check for delete permission (#4313)
This commit is contained in:
parent
30eb11b85e
commit
e90bd136f6
1 changed files with 9 additions and 8 deletions
|
@ -94,16 +94,17 @@ fun String.toCollectionDisplayName(list: List<CollectionView>): String {
|
|||
*
|
||||
* Deletion is allowed when the item is in any collection that the user has "manage" permission for.
|
||||
*/
|
||||
fun List<CollectionView>?.hasDeletePermissionInAtLeastOneCollection(collectionIds: List<String>?) =
|
||||
this
|
||||
?.takeUnless { it.isEmpty() }
|
||||
?.any {
|
||||
fun List<CollectionView>?.hasDeletePermissionInAtLeastOneCollection(
|
||||
collectionIds: List<String>?,
|
||||
): 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.
|
||||
|
|
Loading…
Reference in a new issue