1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-14 10:26:19 +01:00

[PM-13829] Add check for empty array when deleting unassigned items (#11927)

* add check for empty array

---------

Co-authored-by: Matt Bishop <mbishop@bitwarden.com>
This commit is contained in:
Brandon Treston 2024-11-13 14:34:43 -05:00 committed by GitHub
parent 3a293bbf1f
commit 0cfe18ac4d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -713,7 +713,11 @@ export class AddEditComponent implements OnInit, OnDestroy {
}
protected deleteCipher() {
const asAdmin = this.organization?.canEditAllCiphers || !this.cipher.collectionIds;
// cipher.collectionIds may be null or an empty array. Either is a valid indication that the item is unassigned.
const asAdmin =
this.organization?.canEditAllCiphers ||
!this.cipher.collectionIds ||
this.cipher.collectionIds.length === 0;
return this.cipher.isDeleted
? this.cipherService.deleteWithServer(this.cipher.id, asAdmin)
: this.cipherService.softDeleteWithServer(this.cipher.id, asAdmin);