From b2d3688e4dc191e32d41f7b9ecd4bf8711d5d6cd Mon Sep 17 00:00:00 2001 From: Jose Alberto Hernandez Date: Sun, 6 Apr 2025 17:52:31 -0500 Subject: [PATCH] Stop read notifications after user logouts --- src/app/core/shell/sidenav/sidenav.component.ts | 2 +- src/app/core/shell/toolbar/toolbar.component.html | 2 +- src/app/core/shell/toolbar/toolbar.component.ts | 7 ++++++- src/app/home/dashboard/dashboard.component.ts | 2 +- .../notifications-tray/notifications-tray.component.ts | 4 ++++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/app/core/shell/sidenav/sidenav.component.ts b/src/app/core/shell/sidenav/sidenav.component.ts index 0fb7654a6..69d4436e7 100644 --- a/src/app/core/shell/sidenav/sidenav.component.ts +++ b/src/app/core/shell/sidenav/sidenav.component.ts @@ -101,7 +101,7 @@ export class SidenavComponent implements OnInit, AfterViewInit { */ getFrequentActivities() { const frequencyCounts: any = {}; - let index = this.userActivity.length; + let index = this.userActivity?.length; while (index) { frequencyCounts[this.userActivity[--index]] = (frequencyCounts[this.userActivity[index]] || 0) + 1; } diff --git a/src/app/core/shell/toolbar/toolbar.component.html b/src/app/core/shell/toolbar/toolbar.component.html index 5e3944acc..18e201f06 100644 --- a/src/app/core/shell/toolbar/toolbar.component.html +++ b/src/app/core/shell/toolbar/toolbar.component.html @@ -66,7 +66,7 @@
- +
diff --git a/src/app/core/shell/toolbar/toolbar.component.ts b/src/app/core/shell/toolbar/toolbar.component.ts index 0c292ca1c..8d52bf35d 100644 --- a/src/app/core/shell/toolbar/toolbar.component.ts +++ b/src/app/core/shell/toolbar/toolbar.component.ts @@ -28,6 +28,7 @@ import { ConfigurationWizardService } from '../../../configuration-wizard/config /** Custom Components */ import { ConfigurationWizardComponent } from '../../../configuration-wizard/configuration-wizard.component'; +import { NotificationsTrayComponent } from 'app/shared/notifications-tray/notifications-tray.component'; /** * Toolbar component. @@ -46,6 +47,7 @@ export class ToolbarComponent implements OnInit, AfterViewInit, AfterContentChec @ViewChild('appMenu') appMenu: ElementRef; /* Template for popover on appMenu */ @ViewChild('templateAppMenu') templateAppMenu: TemplateRef; + @ViewChild('notificationsTray') notificationsTray: NotificationsTrayComponent; /** Subscription to breakpoint observer for handset. */ isHandset$: Observable = this.breakpointObserver @@ -112,7 +114,10 @@ export class ToolbarComponent implements OnInit, AfterViewInit, AfterContentChec * Logs out the authenticated user and redirects to login page. */ logout() { - this.authenticationService.logout().subscribe(() => this.router.navigate(['/login'], { replaceUrl: true })); + this.authenticationService.logout().subscribe(() => { + this.notificationsTray.destroy(); + this.router.navigate(['/login'], { replaceUrl: true }); + }); } /** diff --git a/src/app/home/dashboard/dashboard.component.ts b/src/app/home/dashboard/dashboard.component.ts index 0a8e471d6..221f0f760 100644 --- a/src/app/home/dashboard/dashboard.component.ts +++ b/src/app/home/dashboard/dashboard.component.ts @@ -69,7 +69,7 @@ export class DashboardComponent implements OnInit { */ getFrequentActivities() { const frequencyCounts: any = {}; - let index = this.userActivity.length; + let index = this.userActivity?.length; while (index) { frequencyCounts[this.userActivity[--index]] = (frequencyCounts[this.userActivity[index]] || 0) + 1; } diff --git a/src/app/shared/notifications-tray/notifications-tray.component.ts b/src/app/shared/notifications-tray/notifications-tray.component.ts index 5bbe68068..f17d1152d 100644 --- a/src/app/shared/notifications-tray/notifications-tray.component.ts +++ b/src/app/shared/notifications-tray/notifications-tray.component.ts @@ -64,6 +64,10 @@ export class NotificationsTrayComponent implements OnInit, OnDestroy { } ngOnDestroy() { + this.destroy(); + } + + public destroy() { clearTimeout(this.timer); }