mirror of
https://github.com/bitwarden/android.git
synced 2024-11-21 08:55:48 +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.
|
* Deletion is allowed when the item is in any collection that the user has "manage" permission for.
|
||||||
*/
|
*/
|
||||||
fun List<CollectionView>?.hasDeletePermissionInAtLeastOneCollection(collectionIds: List<String>?) =
|
fun List<CollectionView>?.hasDeletePermissionInAtLeastOneCollection(
|
||||||
this
|
collectionIds: List<String>?,
|
||||||
?.takeUnless { it.isEmpty() }
|
): Boolean {
|
||||||
?.any {
|
if (this.isNullOrEmpty() || collectionIds.isNullOrEmpty()) return true
|
||||||
|
return this
|
||||||
|
.any { collectionView ->
|
||||||
collectionIds
|
collectionIds
|
||||||
?.contains(it.id)
|
.contains(collectionView.id)
|
||||||
?.let { isInCollection -> !isInCollection || it.manage }
|
.let { isInCollection -> isInCollection && collectionView.manage }
|
||||||
?: true
|
|
||||||
}
|
}
|
||||||
?: true
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the user has permission to assign an item to a collection.
|
* Checks if the user has permission to assign an item to a collection.
|
||||||
|
|
Loading…
Reference in a new issue