mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merged PR 2049: feat(oms): add auto-refresh for open reward tasks
feat(oms): add auto-refresh for open reward tasks Implements 5-minute polling to automatically update open reward tasks without requiring manual page refresh. Uses reference counting to safely handle multiple consumers starting/stopping the refresh. Changes: - Add startAutoRefresh/stopAutoRefresh methods with ref counting - Add lifecycle hooks to carousel component for proper cleanup - Add logging for debugging auto-refresh behavior - Add refresh interval constant (5 minutes) Closes #5463 Related work items: #5463
This commit is contained in:
committed by
Nino Righi
parent
8b852cbd7a
commit
dc26c4de04
@@ -1,4 +1,11 @@
|
||||
import { ChangeDetectionStrategy, Component, computed, inject } from '@angular/core';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
computed,
|
||||
inject,
|
||||
OnInit,
|
||||
OnDestroy,
|
||||
} from '@angular/core';
|
||||
import { OpenRewardTasksResource } from '@isa/oms/data-access';
|
||||
import { CarouselComponent } from '@isa/ui/carousel';
|
||||
import { OpenTaskCardComponent } from './open-task-card.component';
|
||||
@@ -32,7 +39,7 @@ import { OpenTaskCardComponent } from './open-task-card.component';
|
||||
`,
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class OpenTasksCarouselComponent {
|
||||
export class OpenTasksCarouselComponent implements OnInit, OnDestroy {
|
||||
/**
|
||||
* Global resource managing open reward tasks data
|
||||
*/
|
||||
@@ -48,7 +55,7 @@ export class OpenTasksCarouselComponent {
|
||||
const tasks = this.openTasksResource.tasks();
|
||||
const seenOrderIds = new Set<number>();
|
||||
|
||||
return tasks.filter(task => {
|
||||
return tasks.filter((task) => {
|
||||
if (!task.orderId || seenOrderIds.has(task.orderId)) {
|
||||
return false;
|
||||
}
|
||||
@@ -56,4 +63,21 @@ export class OpenTasksCarouselComponent {
|
||||
return true;
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Initializes the component by loading open tasks and starting auto-refresh.
|
||||
* Ensures the carousel displays current data when mounted.
|
||||
*/
|
||||
ngOnInit(): void {
|
||||
this.openTasksResource.refresh();
|
||||
this.openTasksResource.startAutoRefresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleanup lifecycle hook that stops auto-refresh polling.
|
||||
* Prevents memory leaks by clearing the refresh interval.
|
||||
*/
|
||||
ngOnDestroy(): void {
|
||||
this.openTasksResource.stopAutoRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user