Skip to content

Commit

Permalink
remove double backend call on first visit
Browse files Browse the repository at this point in the history
  • Loading branch information
auumgn committed Feb 8, 2024
1 parent 2de390e commit e60495b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ui/src/app/account/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion ui/src/app/account/service/account.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IAccount | null | undefined>(undefined)
private isFetchingAccountData = false
private stopFetchingAccountData = new Subject()
Expand Down Expand Up @@ -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()
}
Expand Down

0 comments on commit e60495b

Please sign in to comment.