docs: add JSDoc comments to SidebarComponent
This commit is contained in:
parent
d2f9734b83
commit
5400c5438d
2 changed files with 35 additions and 0 deletions
|
|
@ -15,10 +15,21 @@ export class SidebarMobileComponent {
|
|||
|
||||
constructor(private router: Router) {}
|
||||
|
||||
/**
|
||||
* Lifecycle hook that is called after the component has been initialized.
|
||||
*
|
||||
* Calls the getCurrentPath method to set the currentPath property to the current route's url.
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.getCurrentPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the current route is one of the add-task routes (add-task, add-task/none, add-task/todo, add-task/inprogress, add-task/awaitfeedback, add-task/done).
|
||||
*
|
||||
* This is used to conditionally render the add-task button in the sidebar.
|
||||
* @returns true if the current route is one of the add-task routes, false otherwise.
|
||||
*/
|
||||
isAddTask(): boolean {
|
||||
return (
|
||||
this.currentPath === 'add-task' ||
|
||||
|
|
@ -30,6 +41,11 @@ export class SidebarMobileComponent {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes to router events and updates the currentPath property
|
||||
* with the current route's URL, excluding the leading slash, whenever
|
||||
* a navigation ends.
|
||||
*/
|
||||
getCurrentPath() {
|
||||
this.router.events.subscribe((event) => {
|
||||
if (event instanceof NavigationEnd) {
|
||||
|
|
|
|||
|
|
@ -23,14 +23,33 @@ export class SidebarComponent implements OnInit {
|
|||
private firebaseService: FirebaseService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Lifecycle hook that is called after the component has been initialized.
|
||||
*
|
||||
* Calls the getCurrentPath method to set the currentPath property to the current route's url.
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.getCurrentPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out the current user and navigates to the login page.
|
||||
*
|
||||
* Calls the logout method of the LoginService with the current user ID as
|
||||
* its argument. This will remove the user ID from the local storage and
|
||||
* perform any other necessary cleanup operations.
|
||||
*
|
||||
* The user is then navigated to the login page.
|
||||
*/
|
||||
logout() {
|
||||
this.loginService.logout(this.firebaseService.getCurrentUserId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Subscribes to router events and updates the currentPath property
|
||||
* with the current route's URL, excluding the leading slash, whenever
|
||||
* a navigation ends.
|
||||
*/
|
||||
getCurrentPath() {
|
||||
this.router.events.subscribe((event) => {
|
||||
if (event instanceof NavigationEnd) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue