@sumaris-net/ngx-components 2.4.151 → 2.4.152
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/src/app/social/user-event/user-event.service.mjs +35 -22
- package/fesm2015/sumaris-net.ngx-components.mjs +31 -21
- package/fesm2015/sumaris-net.ngx-components.mjs.map +1 -1
- package/fesm2020/sumaris-net.ngx-components.mjs +34 -21
- package/fesm2020/sumaris-net.ngx-components.mjs.map +1 -1
- package/package.json +1 -1
- package/src/app/social/user-event/user-event.service.d.ts +5 -0
- package/src/assets/manifest.json +1 -1
|
@@ -33696,6 +33696,7 @@ class AbstractUserEventService extends BaseGraphqlService {
|
|
|
33696
33696
|
this.queries = options.queries;
|
|
33697
33697
|
this.mutations = options.mutations || {};
|
|
33698
33698
|
this.subscriptions = options.subscriptions || {};
|
|
33699
|
+
this.watchQueriesUpdatePolicy = options.watchQueriesUpdatePolicy || 'update-cache';
|
|
33699
33700
|
this._logPrefix = '[user-event-service] ';
|
|
33700
33701
|
}
|
|
33701
33702
|
get countSubject() {
|
|
@@ -33837,10 +33838,21 @@ class AbstractUserEventService extends BaseGraphqlService {
|
|
|
33837
33838
|
return; // Rejected
|
|
33838
33839
|
const withContent = !!entity.content;
|
|
33839
33840
|
// Add user event locally
|
|
33840
|
-
|
|
33841
|
-
|
|
33842
|
-
|
|
33843
|
-
|
|
33841
|
+
if (this.watchQueriesUpdatePolicy === 'update-cache') {
|
|
33842
|
+
if (withContent) {
|
|
33843
|
+
this.insertIntoMutableCachedQueries(this.graphql.cache, {
|
|
33844
|
+
query: this.queries.loadAllWithContent,
|
|
33845
|
+
data: entity
|
|
33846
|
+
});
|
|
33847
|
+
}
|
|
33848
|
+
this.insertIntoMutableCachedQueries(this.graphql.cache, {
|
|
33849
|
+
query: this.queries.loadAll,
|
|
33850
|
+
data: {
|
|
33851
|
+
...entity,
|
|
33852
|
+
content: null
|
|
33853
|
+
}
|
|
33854
|
+
});
|
|
33855
|
+
}
|
|
33844
33856
|
// Update count
|
|
33845
33857
|
this._countSubject.next(this._countSubject.value + 1);
|
|
33846
33858
|
// Add id
|
|
@@ -33954,16 +33966,14 @@ class AbstractUserEventService extends BaseGraphqlService {
|
|
|
33954
33966
|
variables: {
|
|
33955
33967
|
ids
|
|
33956
33968
|
},
|
|
33957
|
-
update: (
|
|
33958
|
-
// Remove from
|
|
33959
|
-
this.
|
|
33960
|
-
|
|
33961
|
-
|
|
33962
|
-
|
|
33963
|
-
|
|
33964
|
-
|
|
33965
|
-
ids
|
|
33966
|
-
});
|
|
33969
|
+
update: (cache) => {
|
|
33970
|
+
// Remove from cache
|
|
33971
|
+
if (this.watchQueriesUpdatePolicy === 'update-cache') {
|
|
33972
|
+
this.removeFromMutableCachedQueriesByIds(cache, {
|
|
33973
|
+
queries: this.getLoadQueries(),
|
|
33974
|
+
ids
|
|
33975
|
+
});
|
|
33976
|
+
}
|
|
33967
33977
|
if (this._debug)
|
|
33968
33978
|
console.debug(`${this._logPrefix}Events deleted in ${Date.now() - now}ms`);
|
|
33969
33979
|
}
|
|
@@ -33991,13 +34001,13 @@ class AbstractUserEventService extends BaseGraphqlService {
|
|
|
33991
34001
|
console.debug(`${this._logPrefix}User event saved in ${Date.now() - now}ms`, entity);
|
|
33992
34002
|
this.copyIdAndUpdateDate(savedEntity, entity);
|
|
33993
34003
|
// Add to cache
|
|
33994
|
-
if (
|
|
33995
|
-
|
|
33996
|
-
|
|
33997
|
-
|
|
33998
|
-
|
|
33999
|
-
|
|
34000
|
-
|
|
34004
|
+
if (this.watchQueriesUpdatePolicy === 'update-cache') {
|
|
34005
|
+
if (withContent) {
|
|
34006
|
+
this.insertIntoMutableCachedQueries(proxy, {
|
|
34007
|
+
query: this.queries.loadAllWithContent,
|
|
34008
|
+
data: savedEntity
|
|
34009
|
+
});
|
|
34010
|
+
}
|
|
34001
34011
|
this.insertIntoMutableCachedQueries(proxy, {
|
|
34002
34012
|
query: this.queries.loadAll,
|
|
34003
34013
|
data: {
|
|
@@ -34148,6 +34158,9 @@ class AbstractUserEventService extends BaseGraphqlService {
|
|
|
34148
34158
|
copyIdAndUpdateDate(source, target) {
|
|
34149
34159
|
EntityUtils.copyIdAndUpdateDate(source, target);
|
|
34150
34160
|
}
|
|
34161
|
+
getLoadQueries() {
|
|
34162
|
+
return [this.queries.loadAll, this.queries.loadAllWithContent].filter(isNotNil);
|
|
34163
|
+
}
|
|
34151
34164
|
}
|
|
34152
34165
|
AbstractUserEventService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AbstractUserEventService, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
|
|
34153
34166
|
AbstractUserEventService.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: AbstractUserEventService, usesInheritance: true, ngImport: i0 });
|