From 854cde2c4a595500bda44b586c63e65b50826485 Mon Sep 17 00:00:00 2001 From: guillermo2519 Date: Wed, 1 Apr 2026 12:22:29 -0600 Subject: [PATCH 1/3] Fix #5331: update system-wide alert preview countdown dynamically --- .../system-wide-alert-form.component.ts | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/app/system-wide-alert/alert-form/system-wide-alert-form.component.ts b/src/app/system-wide-alert/alert-form/system-wide-alert-form.component.ts index 6b5695ca790..ee0be911baf 100644 --- a/src/app/system-wide-alert/alert-form/system-wide-alert-form.component.ts +++ b/src/app/system-wide-alert/alert-form/system-wide-alert-form.component.ts @@ -1,6 +1,7 @@ import { AsyncPipe } from '@angular/common'; import { Component, + OnDestroy, OnInit, } from '@angular/core'; import { @@ -39,7 +40,9 @@ import { import { UiSwitchModule } from 'ngx-ui-switch'; import { BehaviorSubject, + interval, Observable, + Subscription, } from 'rxjs'; import { filter, @@ -67,7 +70,7 @@ import { BtnDisabledDirective } from '../../shared/btn-disabled.directive'; UiSwitchModule, ], }) -export class SystemWideAlertFormComponent implements OnInit { +export class SystemWideAlertFormComponent implements OnInit, OnDestroy { /** * Observable to track an existing system-wide alert @@ -119,6 +122,11 @@ export class SystemWideAlertFormComponent implements OnInit { */ previewDays: number; + /** + * Subscription used to periodically update the preview countdown timer + */ + previewSubscription: Subscription; + constructor( protected systemWideAlertDataService: SystemWideAlertDataService, @@ -153,6 +161,12 @@ export class SystemWideAlertFormComponent implements OnInit { this.currentAlert = alert; this.initFormValues(alert); }); + + this.previewSubscription = interval(1000).subscribe(() => { + if (this.counterEnabled$.getValue() && this.date && this.time) { + this.updatePreviewTime(); + } + }); } /** @@ -231,6 +245,12 @@ export class SystemWideAlertFormComponent implements OnInit { * @param timeDifference - The time difference to calculate and push the time units for */ private allocateTimeUnits(timeDifference) { + if (timeDifference <= 0) { + this.previewMinutes = 0; + this.previewHours = 0; + this.previewDays = 0; + return; + } this.previewMinutes = Math.floor((timeDifference) / (1000 * 60) % 60); this.previewHours = Math.floor((timeDifference) / (1000 * 60 * 60) % 24); this.previewDays = Math.floor((timeDifference) / (1000 * 60 * 60 * 24)); @@ -295,5 +315,11 @@ export class SystemWideAlertFormComponent implements OnInit { this.router.navigate(['/home']); } + ngOnDestroy(): void { + if (this.previewSubscription) { + this.previewSubscription.unsubscribe(); + } + } + } From 043a338009ddd0b43934279edfb3701e02a560f0 Mon Sep 17 00:00:00 2001 From: guillermo2519 Date: Wed, 1 Apr 2026 13:35:03 -0600 Subject: [PATCH 2/3] Fix #5331: fix the Cypress error --- .../alert-form/system-wide-alert-form.component.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/system-wide-alert/alert-form/system-wide-alert-form.component.ts b/src/app/system-wide-alert/alert-form/system-wide-alert-form.component.ts index ee0be911baf..364ab46e312 100644 --- a/src/app/system-wide-alert/alert-form/system-wide-alert-form.component.ts +++ b/src/app/system-wide-alert/alert-form/system-wide-alert-form.component.ts @@ -1,6 +1,7 @@ import { AsyncPipe } from '@angular/common'; import { Component, + NgZone, OnDestroy, OnInit, } from '@angular/core'; @@ -134,6 +135,7 @@ export class SystemWideAlertFormComponent implements OnInit, OnDestroy { protected router: Router, protected requestService: RequestService, protected translateService: TranslateService, + protected ngZone: NgZone, ) { } @@ -162,10 +164,12 @@ export class SystemWideAlertFormComponent implements OnInit, OnDestroy { this.initFormValues(alert); }); - this.previewSubscription = interval(1000).subscribe(() => { - if (this.counterEnabled$.getValue() && this.date && this.time) { - this.updatePreviewTime(); - } + this.ngZone.runOutsideAngular(() => { + this.previewSubscription = interval(1000).subscribe(() => { + if (this.counterEnabled$.getValue() && this.date && this.time) { + this.ngZone.run(() => this.updatePreviewTime()); + } + }); }); } From ff2eb5543e42fdd439df0c53ea208317758f3c24 Mon Sep 17 00:00:00 2001 From: guillermo2519 Date: Wed, 1 Apr 2026 16:01:53 -0600 Subject: [PATCH 3/3] retry CI