feat: account switcher

This commit is contained in:
eneller
2026-07-23 20:19:53 +02:00
parent ed6c8cc413
commit 0619428e07
3 changed files with 20 additions and 5 deletions

View File

@@ -3,7 +3,6 @@ import { Injectable } from '@angular/core';
import { BehaviorSubject, catchError, map, Observable, of, tap } from 'rxjs';
import Transaction from '@model/transaction'
import { SendRequest, SendResponse } from '@message/Send';
import { TransactionsRequest } from '@message/Transactions';
import { LoginResponse } from '@message/Login';
import Account from '@model/user';
@@ -15,6 +14,8 @@ export class APIService {
private isAuthenticatedSubject = new BehaviorSubject<boolean>(false);
isAuthenticated$ = this.isAuthenticatedSubject.asObservable();
// data holding
loggedInUser!: Account;
currentUser!: Account;
ownedAccounts!: Account[];
@@ -25,8 +26,10 @@ export class APIService {
tap({
next: (resp) => {
this.isAuthenticatedSubject.next(true);
this.currentUser = resp.user;
this.loggedInUser = resp.user;
this.currentUser = this.loggedInUser;
this.ownedAccounts = resp.ownedAccounts;
this.ownedAccounts.push(this.loggedInUser);
},
error: () => this.isAuthenticatedSubject.next(false)
})