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

fix: add loading spinner when login / logout still undefined #42

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions apps/frontend/src/app/core/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Router } from '@angular/router'
})
export class AuthService {
private server = new Horizon.Server('https://horizon-testnet.stellar.org')
public loginStatusChanged = new EventEmitter<boolean>() // Emit login status changes
public loginStatusChanged = new EventEmitter<boolean>()

constructor(
private http: HttpClient,
Expand Down Expand Up @@ -72,7 +72,7 @@ export class AuthService {
await this.server.accounts().accountId(publicKey).call()
this.cookieService.set('privateKey', privateKey)
this.cookieService.set('publicKey', publicKey)
this.loginStatusChanged.emit(true) // Notify login status change
this.loginStatusChanged.emit(true)
return true
} catch (error) {
console.error('Account does not exist or cannot be retrieved:', error)
Expand Down Expand Up @@ -104,7 +104,7 @@ export class AuthService {
async logout(): Promise<void> {
this.cookieService.delete('privateKey')
this.cookieService.delete('publicKey')
this.loginStatusChanged.emit(false) // Notify logout status change
this.loginStatusChanged.emit(false)
await this.router.navigate(['/login'])
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@
>About</a
>
</div>
@if (!isLoggedIn) {
@if (isLoggedIn === undefined){
<div class="hidden lg:flex lg:flex-1 lg:justify-end">
<app-loading />
</div>
} @else if (!isLoggedIn) {
<div class="hidden lg:flex lg:flex-1 lg:justify-end">
<a
class="text-sm font-semibold leading-6 text-gray-900 focus:ring-2 focus:ring-gray-500"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import { Component, OnInit, OnDestroy } from '@angular/core'
import { AuthService } from '../../../core/auth.service'
import { Subscription } from 'rxjs'
import { CommonModule, NgOptimizedImage } from '@angular/common'
import { LoadingComponent } from '../../feedback/loading/loading.component'

@Component({
selector: 'app-navbar',
standalone: true,
imports: [CommonModule, NgOptimizedImage],
imports: [CommonModule, NgOptimizedImage, LoadingComponent],
templateUrl: './navbar.component.html',
styleUrls: ['./navbar.component.scss'],
})
export class NavbarComponent implements OnInit, OnDestroy {
isMenuOpen = false
isLoggedIn = false
isLoggedIn: boolean | undefined
private subscription: Subscription = new Subscription()

constructor(private authService: AuthService) {}
Expand Down
Loading