Removed offset and fixed notification polling

This commit is contained in:
Timo Bejan 2024-11-06 15:39:31 +02:00
parent 99facc0434
commit 310cc4bb51

View File

@ -6,7 +6,6 @@ import { HeadersConfiguration } from '../utils/headers-configuration';
import { List } from '../utils/types/iqser-types'; import { List } from '../utils/types/iqser-types';
export const ROOT_CHANGES_KEY = 'root'; export const ROOT_CHANGES_KEY = 'root';
export const LAST_CHECKED_OFFSET = 30000;
export interface QueryParam { export interface QueryParam {
readonly key: string; readonly key: string;
@ -20,7 +19,7 @@ export interface QueryParam {
export abstract class GenericService<I> { export abstract class GenericService<I> {
protected readonly _http = inject(HttpClient); protected readonly _http = inject(HttpClient);
protected readonly _lastCheckedForChanges = new Map<string, string>([ protected readonly _lastCheckedForChanges = new Map<string, string>([
[ROOT_CHANGES_KEY, new Date(Date.now() - LAST_CHECKED_OFFSET).toISOString()], [ROOT_CHANGES_KEY, new Date(Date.now()).toISOString()],
]); ]);
protected abstract readonly _defaultModelPath: string; protected abstract readonly _defaultModelPath: string;
protected readonly _serviceName: string = 'redaction-gateway-v1'; protected readonly _serviceName: string = 'redaction-gateway-v1';
@ -41,7 +40,7 @@ export abstract class GenericService<I> {
headers: HeadersConfiguration.getHeaders({ contentType: false }), headers: HeadersConfiguration.getHeaders({ contentType: false }),
observe: 'body', observe: 'body',
params: this._queryParams(queryParams), params: this._queryParams(queryParams),
}); })
} }
getFor<R = I[]>(entityId: string, queryParams?: List<QueryParam>): Observable<R> { getFor<R = I[]>(entityId: string, queryParams?: List<QueryParam>): Observable<R> {
@ -126,6 +125,7 @@ export abstract class GenericService<I> {
} }
protected _updateLastChanged(key = ROOT_CHANGES_KEY): void { protected _updateLastChanged(key = ROOT_CHANGES_KEY): void {
this._lastCheckedForChanges.set(key, new Date(Date.now() - LAST_CHECKED_OFFSET).toISOString()); console.log(this,'Update last changed for key: ', key ,' to ', new Date().toISOString());
this._lastCheckedForChanges.set(key, new Date().toISOString());
} }
} }