mirror of
https://github.com/bitwarden/browser.git
synced 2024-12-22 16:29:09 +01: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:
parent
0db179e974
commit
4b9935b28c
@ -11,7 +11,6 @@ import { ActivatedRoute, Params, Router } from "@angular/router";
|
||||
import {
|
||||
BehaviorSubject,
|
||||
combineLatest,
|
||||
defer,
|
||||
firstValueFrom,
|
||||
lastValueFrom,
|
||||
Observable,
|
||||
@ -283,27 +282,10 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
|
||||
this.currentSearchText$ = this.route.queryParams.pipe(map((queryParams) => queryParams.search));
|
||||
|
||||
this.allCollectionsWithoutUnassigned$ = combineLatest([
|
||||
organizationId$.pipe(switchMap((orgId) => this.collectionAdminService.getAll(orgId))),
|
||||
defer(() => this.collectionService.getAllDecrypted()),
|
||||
]).pipe(
|
||||
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.allCollectionsWithoutUnassigned$ = this.refresh$.pipe(
|
||||
switchMap(() => organizationId$),
|
||||
switchMap((orgId) => this.collectionAdminService.getAll(orgId)),
|
||||
shareReplay({ refCount: false, bufferSize: 1 }),
|
||||
);
|
||||
|
||||
this.editableCollections$ = this.allCollectionsWithoutUnassigned$.pipe(
|
||||
@ -367,7 +349,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
map((ciphers) => {
|
||||
return Object.fromEntries(ciphers.map((c) => [c.id, c]));
|
||||
}),
|
||||
shareReplay({ refCount: true, bufferSize: 1 }),
|
||||
);
|
||||
|
||||
const nestedCollections$ = allCollections$.pipe(
|
||||
|
Loading…
Reference in New Issue
Block a user