90252: Invalidate requests containing DSO on DataService.delete

Keep track of a list of request UUIDs in the object cache (most recent in front)
When deleting a DSO, mark all of these as stale
This commit is contained in:
Yura Bondarenko
2022-04-07 17:15:07 +02:00
parent 19fa36f243
commit c19d12c5c0
9 changed files with 266 additions and 18 deletions

View File

@@ -311,6 +311,21 @@ export class RequestService {
);
}
/**
* Mark a request as stale
* @param uuid the UUID of the request
* @return an Observable that will emit true once the Request becomes stale
*/
setStaleByUUID(uuid: string): Observable<boolean> {
this.store.dispatch(new RequestStaleAction(uuid));
return this.getByUUID(uuid).pipe(
map(request => isStale(request.state)),
filter(stale => stale === true),
take(1),
);
}
/**
* Check if a GET request is in the cache or if it's still pending
* @param {GetRequest} request The request to check
@@ -339,7 +354,7 @@ export class RequestService {
.subscribe((entry: ObjectCacheEntry) => {
// if the object cache has a match, check if the request that the object came with is
// still valid
inObjCache = this.hasByUUID(entry.requestUUID);
inObjCache = this.hasByUUID(entry.requestUUIDs[0]);
}).unsubscribe();
// we should send the request if it isn't cached