64961: Update bitstream format

This commit is contained in:
Kristof De Langhe
2019-09-16 17:01:03 +02:00
parent 6230fef6b9
commit 358a6522c0
4 changed files with 71 additions and 41 deletions

View File

@@ -211,13 +211,18 @@ export abstract class DataService<T extends CacheableObject> {
* Add a new patch to the object cache
* The patch is derived from the differences between the given object and its version in the object cache
* @param {DSpaceObject} object The given object
* @param extraOperations
*/
update(object: T): Observable<RemoteData<T>> {
update(object: T, extraOperations?: Operation[]): Observable<RemoteData<T>> {
const oldVersion$ = this.objectCache.getObjectBySelfLink(object.self);
return oldVersion$.pipe(take(1), mergeMap((oldVersion: T) => {
const operations = this.comparator.diff(oldVersion, object);
if (isNotEmpty(operations)) {
this.objectCache.addPatch(object.self, operations);
let combinedOperations = operations || extraOperations;
if (isNotEmpty(extraOperations)) {
combinedOperations = [...operations, ...extraOperations];
}
if (isNotEmpty(combinedOperations)) {
this.objectCache.addPatch(object.self, combinedOperations);
}
return this.findById(object.uuid);
}