Skip to content

Commit

Permalink
Merge branch 'feature-process_polling-7.6' into feature-process_polling
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrevryghem committed Feb 19, 2024
2 parents 21cc311 + 8ddc621 commit 049fbb8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
6 changes: 4 additions & 2 deletions src/app/core/data/base/base-data.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ describe('BaseDataService', () => {
const msToLive = 15 * 60 * 1000;
const payload = {
foo: 'bar',
followLink1: {},
followLink2: {},
_links: {
self: Object.assign(new HALLink(), {
href: 'self-test-link',
Expand Down Expand Up @@ -413,7 +415,7 @@ describe('BaseDataService', () => {

expectObservable(service.findByHref(selfLink, false, false, ...linksToFollow)).toBe(expected, values);
flush();
expect(objectCache.addDependency).toHaveBeenCalledTimes(4);
expect(objectCache.addDependency).toHaveBeenCalledTimes(3);
});
});
});
Expand Down Expand Up @@ -621,7 +623,7 @@ describe('BaseDataService', () => {

expectObservable(service.findListByHref(selfLink, findListOptions, false, false, ...linksToFollow)).toBe(expected, values);
flush();
expect(objectCache.addDependency).toHaveBeenCalledTimes(4);
expect(objectCache.addDependency).toHaveBeenCalledTimes(3);
});
});
});
Expand Down
30 changes: 18 additions & 12 deletions src/app/core/data/base/base-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,12 +282,15 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
// Ensure all followLinks from the cached object are automatically invalidated when invalidating the cached object
tap((remoteDataObject: RemoteData<T>) => {
if (hasValue(remoteDataObject?.payload?._links)) {
for (const followLink of Object.values(remoteDataObject.payload._links)) {
// followLink can be either an individual HALLink or a HALLink[]
const followLinksList: HALLink[] = [].concat(followLink);
for (const individualFollowLink of followLinksList) {
if (hasValue(individualFollowLink?.href)) {
this.addDependency(response$, individualFollowLink.href);
for (const followLinkName of Object.keys(remoteDataObject.payload._links)) {
// only add the followLinks if they are embedded
if (hasValue(remoteDataObject.payload[followLinkName]) && followLinkName !== 'self') {
// followLink can be either an individual HALLink or a HALLink[]
const followLinksList: HALLink[] = [].concat(remoteDataObject.payload._links[followLinkName]);
for (const individualFollowLink of followLinksList) {
if (hasValue(individualFollowLink?.href)) {
this.addDependency(response$, individualFollowLink.href);
}
}
}
}
Expand Down Expand Up @@ -334,12 +337,15 @@ export class BaseDataService<T extends CacheableObject> implements HALDataServic
if (hasValue(remoteDataObject?.payload?.page)) {
for (const object of remoteDataObject.payload.page) {
if (hasValue(object?._links)) {
for (const followLink of Object.values(object._links)) {
// followLink can be either an individual HALLink or a HALLink[]
const followLinksList: HALLink[] = [].concat(followLink);
for (const individualFollowLink of followLinksList) {
if (hasValue(individualFollowLink?.href)) {
this.addDependency(response$, individualFollowLink.href);
for (const followLinkName of Object.keys(object._links)) {
// only add the followLinks if they are embedded
if (hasValue(object[followLinkName]) && followLinkName !== 'self') {
// followLink can be either an individual HALLink or a HALLink[]
const followLinksList: HALLink[] = [].concat(object._links[followLinkName]);
for (const individualFollowLink of followLinksList) {
if (hasValue(individualFollowLink?.href)) {
this.addDependency(response$, individualFollowLink.href);
}
}
}
}
Expand Down

0 comments on commit 049fbb8

Please sign in to comment.