mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 00:33:44 +00:00
[PM-12528] AC Fix Collection Refresh (#11207)
* [PM-12528] Ensure collections refresh when the refresh$ subject emits * [PM-12528] Cleanup all collections observable
This commit is contained in:
@@ -11,7 +11,6 @@ import { ActivatedRoute, Params, Router } from "@angular/router";
|
|||||||
import {
|
import {
|
||||||
BehaviorSubject,
|
BehaviorSubject,
|
||||||
combineLatest,
|
combineLatest,
|
||||||
defer,
|
|
||||||
firstValueFrom,
|
firstValueFrom,
|
||||||
lastValueFrom,
|
lastValueFrom,
|
||||||
Observable,
|
Observable,
|
||||||
@@ -283,27 +282,10 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
this.currentSearchText$ = this.route.queryParams.pipe(map((queryParams) => queryParams.search));
|
this.currentSearchText$ = this.route.queryParams.pipe(map((queryParams) => queryParams.search));
|
||||||
|
|
||||||
this.allCollectionsWithoutUnassigned$ = combineLatest([
|
this.allCollectionsWithoutUnassigned$ = this.refresh$.pipe(
|
||||||
organizationId$.pipe(switchMap((orgId) => this.collectionAdminService.getAll(orgId))),
|
switchMap(() => organizationId$),
|
||||||
defer(() => this.collectionService.getAllDecrypted()),
|
switchMap((orgId) => this.collectionAdminService.getAll(orgId)),
|
||||||
]).pipe(
|
shareReplay({ refCount: false, bufferSize: 1 }),
|
||||||
map(([adminCollections, syncCollections]) => {
|
|
||||||
const syncCollectionDict = Object.fromEntries(syncCollections.map((c) => [c.id, c]));
|
|
||||||
|
|
||||||
return adminCollections.map((collection) => {
|
|
||||||
const currentId: any = collection.id;
|
|
||||||
|
|
||||||
const match = syncCollectionDict[currentId];
|
|
||||||
|
|
||||||
if (match) {
|
|
||||||
collection.manage = match.manage;
|
|
||||||
collection.readOnly = match.readOnly;
|
|
||||||
collection.hidePasswords = match.hidePasswords;
|
|
||||||
}
|
|
||||||
return collection;
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
shareReplay({ refCount: true, bufferSize: 1 }),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
this.editableCollections$ = this.allCollectionsWithoutUnassigned$.pipe(
|
this.editableCollections$ = this.allCollectionsWithoutUnassigned$.pipe(
|
||||||
@@ -367,7 +349,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
|||||||
map((ciphers) => {
|
map((ciphers) => {
|
||||||
return Object.fromEntries(ciphers.map((c) => [c.id, c]));
|
return Object.fromEntries(ciphers.map((c) => [c.id, c]));
|
||||||
}),
|
}),
|
||||||
shareReplay({ refCount: true, bufferSize: 1 }),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
const nestedCollections$ = allCollections$.pipe(
|
const nestedCollections$ = allCollections$.pipe(
|
||||||
|
|||||||
Reference in New Issue
Block a user