filter out deleted ciphers in popup service (#10035)

This commit is contained in:
Nick Krantz 2024-07-10 11:44:53 -05:00 committed by GitHub
parent 91294e9c4d
commit c7d64cfc25
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 23 additions and 8 deletions

View File

@ -311,6 +311,19 @@ describe("VaultPopupItemsService", () => {
done();
});
});
it("should return true when all ciphers are deleted", (done) => {
cipherServiceMock.getAllDecrypted.mockResolvedValue([
{ id: "1", type: CipherType.Login, name: "Login 1", isDeleted: true },
{ id: "2", type: CipherType.Login, name: "Login 2", isDeleted: true },
{ id: "3", type: CipherType.Login, name: "Login 3", isDeleted: true },
] as CipherView[]);
service.emptyVault$.subscribe((empty) => {
expect(empty).toBe(true);
done();
});
});
});
describe("noFilteredResults$", () => {

View File

@ -87,14 +87,16 @@ export class VaultPopupItemsService {
map(([organizations, collections]) => {
const orgMap = Object.fromEntries(organizations.map((org) => [org.id, org]));
const collectionMap = Object.fromEntries(collections.map((col) => [col.id, col]));
return ciphers.map(
(cipher) =>
new PopupCipherView(
cipher,
cipher.collectionIds?.map((colId) => collectionMap[colId as CollectionId]),
orgMap[cipher.organizationId as OrganizationId],
),
);
return ciphers
.filter((c) => !c.isDeleted)
.map(
(cipher) =>
new PopupCipherView(
cipher,
cipher.collectionIds?.map((colId) => collectionMap[colId as CollectionId]),
orgMap[cipher.organizationId as OrganizationId],
),
);
}),
),
),