better show filters

This commit is contained in:
2024-04-09 20:33:59 +02:00
parent 3d31594dbc
commit 669bd0d852
9 changed files with 137 additions and 26 deletions

View File

@@ -14,18 +14,7 @@ export class UserService {
private iUserId$ = new BehaviorSubject<string | null>(null);
private iUser$ = new BehaviorSubject<User | null>(null);
public constructor(private afAuth: AngularFireAuth, private db: DbService, private router: Router) {
this.afAuth.authState
.pipe(
filter(auth => !!auth),
map(auth => auth?.uid ?? ''),
tap(uid => this.iUserId$.next(uid)),
switchMap(uid => this.readUser$(uid))
)
.subscribe(_ => this.iUser$.next(_));
this.db.col$<User>('users/').subscribe(_ => this.users$.next(_));
}
public users$ = new BehaviorSubject<User[]>([]);
public get userId$(): Observable<string | null> {
return this.iUserId$.asObservable();
@@ -37,7 +26,22 @@ export class UserService {
public currentUser = async (): Promise<User | null> => firstValueFrom(this.user$);
private users$ = new BehaviorSubject<User[]>([]);
public constructor(
private afAuth: AngularFireAuth,
private db: DbService,
private router: Router
) {
this.afAuth.authState
.pipe(
filter(auth => !!auth),
map(auth => auth?.uid ?? ''),
tap(uid => this.iUserId$.next(uid)),
switchMap(uid => this.readUser$(uid))
)
.subscribe(_ => this.iUser$.next(_));
this.db.col$<User>('users/').subscribe(_ => this.users$.next(_));
}
public getUserbyId = (userId: string): Promise<User | null> => firstValueFrom(this.getUserbyId$(userId));
public getUserbyId$ = (userId: string): Observable<User | null> => this.users$.pipe(map(_ => _.find(f => f.id === userId) || null));