From e60495b09aefa8db76678ae975c6d9ec3d5606be Mon Sep 17 00:00:00 2001 From: andrej romanov <50377758+auumgn@users.noreply.github.com> Date: Thu, 8 Feb 2024 19:42:41 +0200 Subject: [PATCH] remove double backend call on first visit --- ui/src/app/account/login/login.component.ts | 2 +- ui/src/app/account/service/account.service.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ui/src/app/account/login/login.component.ts b/ui/src/app/account/login/login.component.ts index 41450e97e..9969e4782 100644 --- a/ui/src/app/account/login/login.component.ts +++ b/ui/src/app/account/login/login.component.ts @@ -81,7 +81,7 @@ export class LoginComponent implements AfterViewInit, OnDestroy { if (!data.mfaRequired) { this.showMfa = false this.accountService - .getAccountData() + .getAccountData(true) .pipe( filter((account) => !!account), take(1) diff --git a/ui/src/app/account/service/account.service.ts b/ui/src/app/account/service/account.service.ts index 9f121339b..d27e09308 100644 --- a/ui/src/app/account/service/account.service.ts +++ b/ui/src/app/account/service/account.service.ts @@ -11,6 +11,7 @@ import { Router } from '@angular/router' @Injectable({ providedIn: 'root' }) export class AccountService { + // TODO: have unknown and offline instead of undefined and null private accountData = new BehaviorSubject(undefined) private isFetchingAccountData = false private stopFetchingAccountData = new Subject() @@ -138,7 +139,7 @@ export class AccountService { //this.memberService.memberData.next(undefined); this.stopFetchingAccountData.next(true) } - if ((!this.accountData.value && !this.isFetchingAccountData) || force) { + if ((this.accountData.value === undefined && !this.isFetchingAccountData) || force) { this.isFetchingAccountData = true this.fetchAccountData().subscribe() }