mirror of
https://github.com/bitwarden/browser
synced 2026-02-07 04:03:29 +00:00
* Introduce ActiveUserAccessor * Use ActiveUserAccessor over AccountService * Updates tests and testing utils to support ActiveUserAccessor * Update all injection points * Fix types test * Use ternary instead
20 lines
645 B
TypeScript
20 lines
645 B
TypeScript
import { map, Observable } from "rxjs";
|
|
|
|
import { UserId } from "@bitwarden/user-core";
|
|
|
|
import { ActiveUserAccessor } from "../../platform/state";
|
|
import { AccountService } from "../abstractions/account.service";
|
|
|
|
/**
|
|
* Implementation for Platform so they can avoid a direct dependency on AccountService. Not for general consumption.
|
|
*/
|
|
export class DefaultActiveUserAccessor implements ActiveUserAccessor {
|
|
constructor(private readonly accountService: AccountService) {
|
|
this.activeUserId$ = this.accountService.activeAccount$.pipe(
|
|
map((a) => (a != null ? a.id : null)),
|
|
);
|
|
}
|
|
|
|
activeUserId$: Observable<UserId | null>;
|
|
}
|