@sumaris-net/ngx-components 2.4.150 → 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.
@@ -23939,7 +23939,7 @@ class MenuComponent {
23939
23939
  this._subscription.add(this.menuService.opened
23940
23940
  // Avoid duplicated events
23941
23941
  .pipe(distinctUntilChanged())
23942
- .subscribe((value) => (value ? this.open() : this.close())));
23942
+ .subscribe((value) => (value ? this.open({ emitEvent: false }) : this.close({ emitEvent: false }))));
23943
23943
  // TODO : Find a more reliable way to do this :
23944
23944
  // Must be donne after menuService subscription :
23945
23945
  // - In MenuService.ngOnStart accountChanges change will be emitted before the service is ready
@@ -23989,25 +23989,29 @@ class MenuComponent {
23989
23989
  await this.close();
23990
23990
  }
23991
23991
  }
23992
- async open() {
23992
+ async open(opts) {
23993
23993
  console.debug('[menu] Checking open event...');
23994
23994
  const opened = await this.menu.isOpen(this.menuId);
23995
23995
  if (!opened) {
23996
23996
  console.debug('[menu] Opening menu');
23997
23997
  await this.menu.open(this.menuId);
23998
23998
  // Propagate to service
23999
- this.menuService._markAsOpened();
23999
+ if (!opts || opts.emitEvent !== false) {
24000
+ this.menuService._markAsOpened();
24001
+ }
24000
24002
  }
24001
24003
  return true;
24002
24004
  }
24003
- async close() {
24005
+ async close(opts) {
24004
24006
  console.debug('[menu] Checking close event...');
24005
24007
  const opened = await this.menu.isOpen(this.menuId);
24006
24008
  if (opened) {
24007
24009
  console.debug('[menu] Closing menu');
24008
24010
  await this.menu.close(this.menuId);
24009
24011
  // Propagate to service
24010
- this.menuService._markAsClosed();
24012
+ if (!opts || opts.emitEvent !== false) {
24013
+ this.menuService._markAsClosed();
24014
+ }
24011
24015
  }
24012
24016
  return true;
24013
24017
  }
@@ -33692,6 +33696,7 @@ class AbstractUserEventService extends BaseGraphqlService {
33692
33696
  this.queries = options.queries;
33693
33697
  this.mutations = options.mutations || {};
33694
33698
  this.subscriptions = options.subscriptions || {};
33699
+ this.watchQueriesUpdatePolicy = options.watchQueriesUpdatePolicy || 'update-cache';
33695
33700
  this._logPrefix = '[user-event-service] ';
33696
33701
  }
33697
33702
  get countSubject() {
@@ -33833,10 +33838,21 @@ class AbstractUserEventService extends BaseGraphqlService {
33833
33838
  return; // Rejected
33834
33839
  const withContent = !!entity.content;
33835
33840
  // Add user event locally
33836
- this.insertIntoMutableCachedQueries(this.graphql.cache, {
33837
- query: withContent ? this.queries.loadAllWithContent : this.queries.loadAll,
33838
- data: entity
33839
- });
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
+ }
33840
33856
  // Update count
33841
33857
  this._countSubject.next(this._countSubject.value + 1);
33842
33858
  // Add id
@@ -33950,16 +33966,14 @@ class AbstractUserEventService extends BaseGraphqlService {
33950
33966
  variables: {
33951
33967
  ids
33952
33968
  },
33953
- update: (proxy) => {
33954
- // Remove from caches
33955
- this.removeFromMutableCachedQueriesByIds(proxy, {
33956
- query: this.queries.loadAll,
33957
- ids
33958
- });
33959
- this.removeFromMutableCachedQueriesByIds(proxy, {
33960
- query: this.queries.loadAllWithContent,
33961
- ids
33962
- });
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
+ }
33963
33977
  if (this._debug)
33964
33978
  console.debug(`${this._logPrefix}Events deleted in ${Date.now() - now}ms`);
33965
33979
  }
@@ -33987,13 +34001,13 @@ class AbstractUserEventService extends BaseGraphqlService {
33987
34001
  console.debug(`${this._logPrefix}User event saved in ${Date.now() - now}ms`, entity);
33988
34002
  this.copyIdAndUpdateDate(savedEntity, entity);
33989
34003
  // Add to cache
33990
- if (withContent) {
33991
- this.insertIntoMutableCachedQueries(proxy, {
33992
- query: this.queries.loadAllWithContent,
33993
- data: savedEntity
33994
- });
33995
- }
33996
- else {
34004
+ if (this.watchQueriesUpdatePolicy === 'update-cache') {
34005
+ if (withContent) {
34006
+ this.insertIntoMutableCachedQueries(proxy, {
34007
+ query: this.queries.loadAllWithContent,
34008
+ data: savedEntity
34009
+ });
34010
+ }
33997
34011
  this.insertIntoMutableCachedQueries(proxy, {
33998
34012
  query: this.queries.loadAll,
33999
34013
  data: {
@@ -34144,6 +34158,9 @@ class AbstractUserEventService extends BaseGraphqlService {
34144
34158
  copyIdAndUpdateDate(source, target) {
34145
34159
  EntityUtils.copyIdAndUpdateDate(source, target);
34146
34160
  }
34161
+ getLoadQueries() {
34162
+ return [this.queries.loadAll, this.queries.loadAllWithContent].filter(isNotNil);
34163
+ }
34147
34164
  }
34148
34165
  AbstractUserEventService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AbstractUserEventService, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
34149
34166
  AbstractUserEventService.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: AbstractUserEventService, usesInheritance: true, ngImport: i0 });