RED-10414 Removed offset and fixed notification polling

This commit is contained in:
Timo Bejan 2024-11-06 15:42:37 +02:00
parent f26772d4a0
commit bc7e2483c2
3 changed files with 13 additions and 5 deletions

View File

@ -1,4 +1,4 @@
import { GenericService, LAST_CHECKED_OFFSET, QueryParam, ROOT_CHANGES_KEY } from '@iqser/common-ui'; import { GenericService, QueryParam, ROOT_CHANGES_KEY } from '@iqser/common-ui';
import { Dossier, DossierStats, IDossierChanges } from '@red/domain'; import { Dossier, DossierStats, IDossierChanges } from '@red/domain';
import { forkJoin, Observable, of, Subscription, throwError, timer } from 'rxjs'; import { forkJoin, Observable, of, Subscription, throwError, timer } from 'rxjs';
import { catchError, filter, map, switchMap, take, tap } from 'rxjs/operators'; import { catchError, filter, map, switchMap, take, tap } from 'rxjs/operators';
@ -47,7 +47,7 @@ export class DossiersChangesService extends GenericService<Dossier> implements O
hasChangesDetails$(): Observable<IDossierChanges> { hasChangesDetails$(): Observable<IDossierChanges> {
const body = { value: this._lastCheckedForChanges.get(ROOT_CHANGES_KEY) }; const body = { value: this._lastCheckedForChanges.get(ROOT_CHANGES_KEY) };
const dateBeforeRequest = new Date(Date.now() - LAST_CHECKED_OFFSET).toISOString(); const dateBeforeRequest = new Date().toISOString();
this.#logger.info('[DOSSIERS_CHANGES] Check with Last Checked Date', body.value); this.#logger.info('[DOSSIERS_CHANGES] Check with Last Checked Date', body.value);

View File

@ -1,7 +1,7 @@
import { inject, Injectable, OnDestroy } from '@angular/core'; import { inject, Injectable, OnDestroy } from '@angular/core';
import { EntitiesService, getConfig, QueryParam } from '@iqser/common-ui'; import { EntitiesService, getConfig, QueryParam } from '@iqser/common-ui';
import { TranslateService } from '@ngx-translate/core'; import { TranslateService } from '@ngx-translate/core';
import { EMPTY, firstValueFrom, iif, merge, Observable, of, Subscription, timer } from 'rxjs'; import { EMPTY, firstValueFrom, merge, Observable, of, Subscription, timer } from 'rxjs';
import { AppConfig, Dossier, INotification, Notification, NotificationTypes } from '@red/domain'; import { AppConfig, Dossier, INotification, Notification, NotificationTypes } from '@red/domain';
import { map, switchMap, tap } from 'rxjs/operators'; import { map, switchMap, tap } from 'rxjs/operators';
import { notificationsTranslations } from '@translations/notifications-translations'; import { notificationsTranslations } from '@translations/notifications-translations';
@ -141,6 +141,14 @@ export class NotificationsService extends EntitiesService<INotification, Notific
} }
#loadNotificationsIfChanged(): Observable<Notification[]> { #loadNotificationsIfChanged(): Observable<Notification[]> {
return this.hasChanges$().pipe(switchMap(changed => iif(() => changed, this.loadAll(), EMPTY))); return this.hasChanges$().pipe(
switchMap(changed => {
if (changed) {
return this.loadAll();
} else {
return EMPTY;
}
}),
);
} }
} }

@ -1 +1 @@
Subproject commit 99facc0434006e7d86bcaf032febfdb19cb9956c Subproject commit 310cc4bb516b6ac049bce4a85bcb8796a2d4f54e