update angular version
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {DbService} from './db.service';
|
||||
import {Observable} from 'rxjs';
|
||||
import {firstValueFrom, Observable} from 'rxjs';
|
||||
import {Config} from './config';
|
||||
import {first} from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
@@ -10,11 +9,7 @@ import {first} from 'rxjs/operators';
|
||||
export class ConfigService {
|
||||
public constructor(private db: DbService) {}
|
||||
|
||||
public get get$(): Observable<Config | null> {
|
||||
return this.db.doc$<Config>('global/config');
|
||||
}
|
||||
public get$ = (): Observable<Config | null> => this.db.doc$<Config>('global/config');
|
||||
public get = (): Promise<Config | null> => firstValueFrom(this.get$());
|
||||
|
||||
public async get(): Promise<Config | null> {
|
||||
return await this.db.doc$<Config>('global/config').pipe(first()).toPromise();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument} from '@angular/fire/firestore';
|
||||
import {AngularFirestore, AngularFirestoreCollection, AngularFirestoreDocument} from '@angular/fire/compat/firestore';
|
||||
import {Observable} from 'rxjs';
|
||||
import {QueryFn} from '@angular/fire/firestore/interfaces';
|
||||
import {QueryFn} from '@angular/fire/compat/firestore/interfaces';
|
||||
import {map} from 'rxjs/operators';
|
||||
|
||||
type CollectionPredicate<T> = string | AngularFirestoreCollection<T>;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {AngularFireAuth} from '@angular/fire/auth';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {filter, first, map, switchMap, tap} from 'rxjs/operators';
|
||||
import {AngularFireAuth} from '@angular/fire/compat/auth';
|
||||
import {BehaviorSubject, firstValueFrom, Observable} from 'rxjs';
|
||||
import {filter, map, switchMap, tap} from 'rxjs/operators';
|
||||
import {User} from './user';
|
||||
import {DbService} from '../db.service';
|
||||
import {environment} from '../../../environments/environment';
|
||||
@@ -33,17 +33,10 @@ export class UserService {
|
||||
return this.iUser$.pipe(filter(_ => !!_));
|
||||
}
|
||||
|
||||
public async currentUser(): Promise<User | null> {
|
||||
return this.user$.pipe(first()).toPromise();
|
||||
}
|
||||
public currentUser = async (): Promise<User | null> => firstValueFrom(this.user$);
|
||||
|
||||
public getUserbyId(userId: string): Promise<User | null> {
|
||||
return this.getUserbyId$(userId).pipe(first()).toPromise();
|
||||
}
|
||||
|
||||
public getUserbyId$(userId: string): Observable<User | null> {
|
||||
return this.db.doc$<User>('users/' + userId);
|
||||
}
|
||||
public getUserbyId = (userId: string): Promise<User | null> => firstValueFrom(this.getUserbyId$(userId));
|
||||
public getUserbyId$ = (userId: string): Observable<User | null> => this.db.doc$<User>('users/' + userId);
|
||||
|
||||
public async login(user: string, password: string): Promise<string | null> {
|
||||
const aUser = await this.afAuth.signInWithEmailAndPassword(user, password);
|
||||
@@ -83,6 +76,6 @@ export class UserService {
|
||||
await this.router.navigateByUrl('/brand/new-user');
|
||||
}
|
||||
|
||||
private readUser$ = (uid: string) => this.db.doc$<User | null>('users/' + uid);
|
||||
private readUser = async (uid: string): Promise<User | null> => await this.readUser$(uid).pipe(first()).toPromise();
|
||||
private readUser$ = (uid: string) => this.db.doc$<User>('users/' + uid);
|
||||
private readUser: (uid: string) => Promise<User | null> = (uid: string) => firstValueFrom(this.readUser$(uid));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user