Handle no users case for auth service statuses

This commit is contained in:
Matt Gibson 2024-04-25 08:49:24 -04:00
parent 92f85beb8d
commit 4aef033a81
No known key found for this signature in database
GPG Key ID: 963EE038B0581878
1 changed files with 7 additions and 4 deletions

View File

@ -40,13 +40,16 @@ export class AuthService implements AuthServiceAbstraction {
this.authStatuses$ = this.accountService.accounts$.pipe(
map((accounts) => Object.keys(accounts) as UserId[]),
switchMap((entries) =>
combineLatest(
switchMap((entries) => {
if (entries.length === 0) {
return of([] as { userId: UserId; status: AuthenticationStatus }[]);
}
return combineLatest(
entries.map((userId) =>
this.authStatusFor$(userId).pipe(map((status) => ({ userId, status }))),
),
),
),
);
}),
map((statuses) => {
return statuses.reduce(
(acc, { userId, status }) => {