Bernd-L/exDateMan

View on GitHub
frontend/src/app/components/side-nav/side-nav.component.ts

Summary

Maintainability
A
2 hrs
Test Coverage
import { Component, OnInit } from "@angular/core";
import {
AuthService,
GetStatusResponse
} from "../../services/auth/auth.service";
 
@Component({
selector: "app-side-nav",
templateUrl: "./side-nav.component.html",
styleUrls: ["./side-nav.component.scss"]
})
export class SideNavComponent implements OnInit {
/**
* A flag set while the component is loading its data
*/
loading = true;
 
/**
* The user, cached here
*/
authStatus: GetStatusResponse = {} as GetStatusResponse;
 
constructor(private as: AuthService) {}
 
Identical blocks of code found in 2 locations. Consider refactoring.
async ngOnInit(): Promise<void> {
await this.testLogin();
document.addEventListener("auth", () => this.testLogin());
}
 
/**
* Tests if the user is logged in
*/
Identical blocks of code found in 2 locations. Consider refactoring.
async testLogin(): Promise<void> {
const res = await this.as.getCurrentUser();
 
this.authStatus = res;
 
this.loading = false;
}
}