From 65907b7b392a60deba1f6779e12382a4834f5c76 Mon Sep 17 00:00:00 2001
From: kbeyro <121854496+kbeyro@users.noreply.github.com>
Date: Fri, 13 Jun 2025 11:21:23 +0200
Subject: [PATCH] dont trigger refresh in backgroud

---
 .../admin-dashboard/admin-dashboard.component.ts  | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/src/app/shared/admin-dashboard/admin-dashboard.component.ts b/src/app/shared/admin-dashboard/admin-dashboard.component.ts
index c08b0efc..beb225db 100644
--- a/src/app/shared/admin-dashboard/admin-dashboard.component.ts
+++ b/src/app/shared/admin-dashboard/admin-dashboard.component.ts
@@ -1,4 +1,4 @@
-import { Component } from '@angular/core';
+import { Component, OnDestroy, OnInit } from '@angular/core';
 import {DashboardService} from '../../service/dashboard.service';
 import {UserDataService} from '../../service/userdata.service';
 import {AppImagesService, AppsService} from '../../service';
@@ -10,7 +10,7 @@ import {AuthService} from '../../auth/auth.service';
   templateUrl: './admin-dashboard.component.html',
   styleUrl: './admin-dashboard.component.css'
 })
-export class AdminDashboardComponent {
+export class AdminDashboardComponent implements OnInit, OnDestroy {
   popularAppsChartData: any;
 
   basicOptions: any;
@@ -26,6 +26,8 @@ export class AdminDashboardComponent {
   startDate;
   endDate;
 
+  private refresh : any;
+
   constructor(protected dashboardService: DashboardService,
               private userDataService: UserDataService,
               public appImagesService: AppImagesService,
@@ -35,10 +37,10 @@ export class AdminDashboardComponent {
   }
 
 
-  ngOnInit() {
+  public ngOnInit() {
     this.setDefaultDate();
     this.getAdmin()
-    this.userDataService.selectedDomainId.subscribe((domainId) => {
+    this.refresh = this.userDataService.selectedDomainId.subscribe((domainId) => {
           this.domainId = domainId
           this.getDomainAdmin()
     });
@@ -84,6 +86,11 @@ export class AdminDashboardComponent {
     };
   }
 
+  public ngOnDestroy(): void {
+    this.refresh.unsubscribe();
+    this.refresh = null;
+  }
+
   chartData() {
     const entries = Object.entries(this.adminData.popularApps);
     const sortedEntries = entries.sort((a, b) =>  Number(b[1]) -  Number(a[1]));
-- 
GitLab