1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-07 04:03:29 +00:00
Files
browser/libs/common/src/auth/services/default-active-user.accessor.ts
Justin Baur 4f9b2b618f [PM-24280] Remove account service from state (#15828)
* Introduce ActiveUserAccessor

* Use ActiveUserAccessor over AccountService

* Updates tests and testing utils to support ActiveUserAccessor

* Update all injection points

* Fix types test

* Use ternary instead
2025-07-31 09:09:14 -04:00

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>;
}