Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove double backend call on first load #1115

Merged
merged 1 commit into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -72,8 +72,8 @@

this.loginService
.login({
username: this.loginForm.get('username')!.value!,

Check warning on line 75 in ui/src/app/account/login/login.component.ts

View workflow job for this annotation

GitHub Actions / format

Forbidden non-null assertion

Check warning on line 75 in ui/src/app/account/login/login.component.ts

View workflow job for this annotation

GitHub Actions / format

Forbidden non-null assertion
password: this.loginForm.get('password')!.value!,

Check warning on line 76 in ui/src/app/account/login/login.component.ts

View workflow job for this annotation

GitHub Actions / format

Forbidden non-null assertion

Check warning on line 76 in ui/src/app/account/login/login.component.ts

View workflow job for this annotation

GitHub Actions / format

Forbidden non-null assertion
mfaCode: this.loginForm.get('mfaCode')?.value,
})
.subscribe({
Expand All @@ -81,7 +81,7 @@
if (!data.mfaRequired) {
this.showMfa = false
this.accountService
.getAccountData()
.getAccountData(true)
.pipe(
filter((account) => !!account),
take(1)
Expand All @@ -96,7 +96,7 @@
this.mfaSent = false
},
// TODO: review any type
error: (err) => {

Check warning on line 99 in ui/src/app/account/login/login.component.ts

View workflow job for this annotation

GitHub Actions / format

'err' is defined but never used
this.loginService.logout()
this.authenticationError = true
},
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
Loading