chore: shitty ahh rebase
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				CI / Get Changed Files (pull_request) Successful in 10s
				
			
		
			
				
	
				CI / Docker backend validation (pull_request) Successful in 10s
				
			
		
			
				
	
				CI / oxlint (pull_request) Successful in 28s
				
			
		
			
				
	
				CI / Docker frontend validation (pull_request) Successful in 43s
				
			
		
			
				
	
				CI / eslint (pull_request) Successful in 34s
				
			
		
			
				
	
				CI / Checkstyle Main (pull_request) Successful in 46s
				
			
		
			
				
	
				CI / prettier (pull_request) Failing after 24s
				
			
		
			
				
	
				CI / test-build (pull_request) Successful in 34s
				
			
		
		
	
	
		
	
		
			Some checks failed
		
		
	
	CI / Get Changed Files (pull_request) Successful in 10s
				
			CI / Docker backend validation (pull_request) Successful in 10s
				
			CI / oxlint (pull_request) Successful in 28s
				
			CI / Docker frontend validation (pull_request) Successful in 43s
				
			CI / eslint (pull_request) Successful in 34s
				
			CI / Checkstyle Main (pull_request) Successful in 46s
				
			CI / prettier (pull_request) Failing after 24s
				
			CI / test-build (pull_request) Successful in 34s
				
			This commit is contained in:
		
					parent
					
						
							
								84250969aa
							
						
					
				
			
			
				commit
				
					
						91e546226d
					
				
			
		
					 2 changed files with 7 additions and 10 deletions
				
			
		|  | @ -2,22 +2,20 @@ import { inject, Injectable } from '@angular/core'; | |||
| import { HttpClient } from '@angular/common/http'; | ||||
| import { BehaviorSubject, catchError, EMPTY, Observable, tap } from 'rxjs'; | ||||
| import { User } from '../model/User'; | ||||
| import { environment } from '@environments/environment'; | ||||
| import { AuthService } from '@service/auth.service'; | ||||
| 
 | ||||
| @Injectable({ | ||||
|   providedIn: 'root', | ||||
| }) | ||||
| export class UserService { | ||||
|   private apiUrl = `${environment.apiUrl}/users`; | ||||
| 
 | ||||
|   private currentUserSubject = new BehaviorSubject<User | null>(null); | ||||
|   public currentUserSubject = new BehaviorSubject<User | null>(null); | ||||
|   public currentUser$ = this.currentUserSubject.asObservable(); | ||||
|   private http: HttpClient = inject(HttpClient); | ||||
|   private authService: AuthService = inject(AuthService); | ||||
|   private authService = inject(AuthService); | ||||
| 
 | ||||
| 
 | ||||
|   public getCurrentUser(): Observable<User | null> { | ||||
|     return this.http.get<User | null>('/backend/user').pipe( | ||||
|     return this.http.get<User | null>('/backend/users/me').pipe( | ||||
|       catchError(() => EMPTY), | ||||
|       tap((user) => this.currentUserSubject.next(user)) | ||||
|     ); | ||||
|  | @ -25,6 +23,7 @@ export class UserService { | |||
| 
 | ||||
|   public refreshCurrentUser(): void { | ||||
|     this.getCurrentUser().subscribe(); | ||||
|     this.authService.loadCurrentUser(); | ||||
|   } | ||||
| 
 | ||||
|   public updateLocalBalance(amount: number): void { | ||||
|  | @ -37,8 +36,4 @@ export class UserService { | |||
|       this.currentUserSubject.next(updatedUser); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   public refreshCurrentUser(): void { | ||||
|     this.authService.loadCurrentUser(); | ||||
|   } | ||||
| } | ||||
|  |  | |||
|  | @ -3,6 +3,7 @@ import { RouterModule } from '@angular/router'; | |||
| import { AuthService } from '@service/auth.service'; | ||||
| import { Subscription } from 'rxjs'; | ||||
| import { AnimatedNumberComponent } from '@blackjack/components/animated-number/animated-number.component'; | ||||
| import { UserService } from '@service/user.service'; | ||||
| 
 | ||||
| @Component({ | ||||
|   selector: 'app-navbar', | ||||
|  | @ -19,6 +20,7 @@ export class NavbarComponent implements OnInit, OnDestroy { | |||
|   private userSubscription: Subscription | undefined; | ||||
|   private authSubscription: Subscription | undefined; | ||||
|   public balance = signal(0); | ||||
|   private userService = inject(UserService); | ||||
| 
 | ||||
|   ngOnInit() { | ||||
|     // Subscribe to auth changes
 | ||||
|  |  | |||
		Reference in a new issue