Skip to content

Commit 4fac876

Browse files
CopilotPhantomDave
andauthored
refactor: Remove duplicate layout components and fix memory leaks (#95)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: PhantomDave <34485699+PhantomDave@users.noreply.github.com>
1 parent 47edd92 commit 4fac876

7 files changed

Lines changed: 19 additions & 42 deletions

File tree

frontend/src/app/app.routes.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,13 @@ import { ImportWizardComponent } from './components/import/import-wizard-compone
99
import { MonthlyComparisonComponent } from './components/analytics/monthly-comparison-component/monthly-comparison-component';
1010
import { TrackingComponent } from './components/tracking/tracking/tracking.component';
1111
import { DashboardComponent } from './components/dashboard-component/dashboard-component.component';
12-
import { HomeLayoutComponent } from './layouts/home-layout/home-layout.component';
13-
import { MovementsLayoutComponent } from './layouts/movements-layout/movements-layout.component';
14-
import { AnalyticsLayoutComponent } from './layouts/analytics-layout/analytics-layout.component';
1512

1613
export const routes: Routes = [
1714
{ path: '', redirectTo: 'login', pathMatch: 'full' },
1815
{ path: 'login', component: LoginComponent, data: { breadcrumb: 'Login' } },
1916
{ path: 'register', component: RegisterComponent, data: { breadcrumb: 'Register' } },
2017
{
2118
path: 'home',
22-
component: HomeLayoutComponent,
2319
canActivate: [authenticateGuard],
2420
data: { breadcrumb: 'Home' },
2521
children: [
@@ -30,7 +26,6 @@ export const routes: Routes = [
3026
},
3127
{
3228
path: 'movements',
33-
component: MovementsLayoutComponent,
3429
canActivate: [authenticateGuard],
3530
data: { breadcrumb: 'Movements' },
3631
children: [
@@ -41,7 +36,6 @@ export const routes: Routes = [
4136
},
4237
{
4338
path: 'analytics',
44-
component: AnalyticsLayoutComponent,
4539
canActivate: [authenticateGuard],
4640
data: { breadcrumb: 'Analytics' },
4741
children: [

frontend/src/app/components/side-nav-component/side-nav-component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
<mat-divider></mat-divider>
104104

105105
<mat-nav-list aria-label="Account actions" class="account-actions">
106-
<a mat-list-item (click)="onToggleTheme()" tabindex="0" role="button">
106+
<a mat-list-item (click)="onToggleTheme()" (keydown.enter)="onToggleTheme(); $event.preventDefault()" (keydown.space)="onToggleTheme(); $event.preventDefault()" tabindex="0" role="button">
107107
<mat-icon matListItemIcon>
108108
@if (themeService.isDarkMode()) {
109109
light_mode
@@ -129,7 +129,7 @@
129129
<mat-icon matListItemIcon>settings</mat-icon>
130130
<span matListItemTitle>Settings</span>
131131
</a>
132-
<a mat-list-item (click)="onLogout()" tabindex="0" role="button">
132+
<a mat-list-item (click)="onLogout()" (keydown.enter)="onLogout(); $event.preventDefault()" (keydown.space)="onLogout(); $event.preventDefault()" tabindex="0" role="button">
133133
<mat-icon matListItemIcon>logout</mat-icon>
134134
<span matListItemTitle>Logout</span>
135135
</a>

frontend/src/app/components/side-nav-component/side-nav-component.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { ChangeDetectionStrategy, Component, inject, OnInit, signal } from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, inject, signal } from '@angular/core';
2+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
23
import { MatIconButton } from '@angular/material/button';
34
import { MatIcon } from '@angular/material/icon';
45
import { MatListItem, MatListItemIcon, MatListItemTitle, MatNavList } from '@angular/material/list';
@@ -44,7 +45,7 @@ import { BreadcrumbComponent } from '../ui-library/breadcrumb/breadcrumb.compone
4445
styleUrl: './side-nav-component.css',
4546
changeDetection: ChangeDetectionStrategy.OnPush,
4647
})
47-
export class SideNavComponent implements OnInit {
48+
export class SideNavComponent {
4849
private readonly accountService = inject(AccountService);
4950
private readonly router = inject(Router);
5051
protected readonly themeService = inject(ThemeService);
@@ -54,13 +55,16 @@ export class SideNavComponent implements OnInit {
5455
protected readonly movementsExpanded = signal(false);
5556
protected readonly analyticsExpanded = signal(false);
5657

57-
ngOnInit(): void {
58+
constructor() {
5859
// Set initial state based on current route
5960
this.updateExpandedPanels(this.router.url);
6061

6162
// Listen to route changes and update expanded panels
6263
this.router.events
63-
.pipe(filter((event): event is NavigationEnd => event instanceof NavigationEnd))
64+
.pipe(
65+
filter((event): event is NavigationEnd => event instanceof NavigationEnd),
66+
takeUntilDestroyed()
67+
)
6468
.subscribe((event: NavigationEnd) => {
6569
this.updateExpandedPanels(event.urlAfterRedirects);
6670
});

frontend/src/app/components/ui-library/breadcrumb/breadcrumb.component.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Component, inject, signal } from '@angular/core';
2+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
23
import { MatChipsModule } from '@angular/material/chips';
34
import { FlexComponent } from '../flex-component/flex-component';
45
import { Router, ActivatedRoute, NavigationEnd, RouterModule } from '@angular/router';
@@ -23,9 +24,14 @@ export class BreadcrumbComponent {
2324

2425
constructor() {
2526
// Update breadcrumbs on navigation
26-
this.router.events.pipe(filter((event) => event instanceof NavigationEnd)).subscribe(() => {
27-
this.breadcrumbs.set(this.createBreadcrumbs(this.activatedRoute.root));
28-
});
27+
this.router.events
28+
.pipe(
29+
filter((event) => event instanceof NavigationEnd),
30+
takeUntilDestroyed()
31+
)
32+
.subscribe(() => {
33+
this.breadcrumbs.set(this.createBreadcrumbs(this.activatedRoute.root));
34+
});
2935

3036
// Initial load
3137
this.breadcrumbs.set(this.createBreadcrumbs(this.activatedRoute.root));

frontend/src/app/layouts/analytics-layout/analytics-layout.component.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

frontend/src/app/layouts/home-layout/home-layout.component.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

frontend/src/app/layouts/movements-layout/movements-layout.component.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

0 commit comments

Comments
 (0)