@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.
@@ -24336,7 +24336,7 @@ class MenuComponent {
24336
24336
  this._subscription.add(this.menuService.opened
24337
24337
  // Avoid duplicated events
24338
24338
  .pipe(distinctUntilChanged())
24339
- .subscribe((value) => (value ? this.open() : this.close())));
24339
+ .subscribe((value) => (value ? this.open({ emitEvent: false }) : this.close({ emitEvent: false }))));
24340
24340
  // TODO : Find a more reliable way to do this :
24341
24341
  // Must be donne after menuService subscription :
24342
24342
  // - In MenuService.ngOnStart accountChanges change will be emitted before the service is ready
@@ -24393,7 +24393,7 @@ class MenuComponent {
24393
24393
  }
24394
24394
  });
24395
24395
  }
24396
- open() {
24396
+ open(opts) {
24397
24397
  return __awaiter(this, void 0, void 0, function* () {
24398
24398
  console.debug('[menu] Checking open event...');
24399
24399
  const opened = yield this.menu.isOpen(this.menuId);
@@ -24401,12 +24401,14 @@ class MenuComponent {
24401
24401
  console.debug('[menu] Opening menu');
24402
24402
  yield this.menu.open(this.menuId);
24403
24403
  // Propagate to service
24404
- this.menuService._markAsOpened();
24404
+ if (!opts || opts.emitEvent !== false) {
24405
+ this.menuService._markAsOpened();
24406
+ }
24405
24407
  }
24406
24408
  return true;
24407
24409
  });
24408
24410
  }
24409
- close() {
24411
+ close(opts) {
24410
24412
  return __awaiter(this, void 0, void 0, function* () {
24411
24413
  console.debug('[menu] Checking close event...');
24412
24414
  const opened = yield this.menu.isOpen(this.menuId);
@@ -24414,7 +24416,9 @@ class MenuComponent {
24414
24416
  console.debug('[menu] Closing menu');
24415
24417
  yield this.menu.close(this.menuId);
24416
24418
  // Propagate to service
24417
- this.menuService._markAsClosed();
24419
+ if (!opts || opts.emitEvent !== false) {
24420
+ this.menuService._markAsClosed();
24421
+ }
24418
24422
  }
24419
24423
  return true;
24420
24424
  });
@@ -34493,6 +34497,7 @@ class AbstractUserEventService extends BaseGraphqlService {
34493
34497
  this.queries = options.queries;
34494
34498
  this.mutations = options.mutations || {};
34495
34499
  this.subscriptions = options.subscriptions || {};
34500
+ this.watchQueriesUpdatePolicy = options.watchQueriesUpdatePolicy || 'update-cache';
34496
34501
  this._logPrefix = '[user-event-service] ';
34497
34502
  }
34498
34503
  get countSubject() {
@@ -34637,10 +34642,18 @@ class AbstractUserEventService extends BaseGraphqlService {
34637
34642
  return; // Rejected
34638
34643
  const withContent = !!entity.content;
34639
34644
  // Add user event locally
34640
- this.insertIntoMutableCachedQueries(this.graphql.cache, {
34641
- query: withContent ? this.queries.loadAllWithContent : this.queries.loadAll,
34642
- data: entity
34643
- });
34645
+ if (this.watchQueriesUpdatePolicy === 'update-cache') {
34646
+ if (withContent) {
34647
+ this.insertIntoMutableCachedQueries(this.graphql.cache, {
34648
+ query: this.queries.loadAllWithContent,
34649
+ data: entity
34650
+ });
34651
+ }
34652
+ this.insertIntoMutableCachedQueries(this.graphql.cache, {
34653
+ query: this.queries.loadAll,
34654
+ data: Object.assign(Object.assign({}, entity), { content: null })
34655
+ });
34656
+ }
34644
34657
  // Update count
34645
34658
  this._countSubject.next(this._countSubject.value + 1);
34646
34659
  // Add id
@@ -34763,16 +34776,14 @@ class AbstractUserEventService extends BaseGraphqlService {
34763
34776
  variables: {
34764
34777
  ids
34765
34778
  },
34766
- update: (proxy) => {
34767
- // Remove from caches
34768
- this.removeFromMutableCachedQueriesByIds(proxy, {
34769
- query: this.queries.loadAll,
34770
- ids
34771
- });
34772
- this.removeFromMutableCachedQueriesByIds(proxy, {
34773
- query: this.queries.loadAllWithContent,
34774
- ids
34775
- });
34779
+ update: (cache) => {
34780
+ // Remove from cache
34781
+ if (this.watchQueriesUpdatePolicy === 'update-cache') {
34782
+ this.removeFromMutableCachedQueriesByIds(cache, {
34783
+ queries: this.getLoadQueries(),
34784
+ ids
34785
+ });
34786
+ }
34776
34787
  if (this._debug)
34777
34788
  console.debug(`${this._logPrefix}Events deleted in ${Date.now() - now}ms`);
34778
34789
  }
@@ -34802,13 +34813,13 @@ class AbstractUserEventService extends BaseGraphqlService {
34802
34813
  console.debug(`${this._logPrefix}User event saved in ${Date.now() - now}ms`, entity);
34803
34814
  this.copyIdAndUpdateDate(savedEntity, entity);
34804
34815
  // Add to cache
34805
- if (withContent) {
34806
- this.insertIntoMutableCachedQueries(proxy, {
34807
- query: this.queries.loadAllWithContent,
34808
- data: savedEntity
34809
- });
34810
- }
34811
- else {
34816
+ if (this.watchQueriesUpdatePolicy === 'update-cache') {
34817
+ if (withContent) {
34818
+ this.insertIntoMutableCachedQueries(proxy, {
34819
+ query: this.queries.loadAllWithContent,
34820
+ data: savedEntity
34821
+ });
34822
+ }
34812
34823
  this.insertIntoMutableCachedQueries(proxy, {
34813
34824
  query: this.queries.loadAll,
34814
34825
  data: Object.assign(Object.assign({}, savedEntity), { content: null })
@@ -34969,6 +34980,9 @@ class AbstractUserEventService extends BaseGraphqlService {
34969
34980
  copyIdAndUpdateDate(source, target) {
34970
34981
  EntityUtils.copyIdAndUpdateDate(source, target);
34971
34982
  }
34983
+ getLoadQueries() {
34984
+ return [this.queries.loadAll, this.queries.loadAllWithContent].filter(isNotNil);
34985
+ }
34972
34986
  }
34973
34987
  AbstractUserEventService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.3.0", ngImport: i0, type: AbstractUserEventService, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
34974
34988
  AbstractUserEventService.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.3.0", type: AbstractUserEventService, usesInheritance: true, ngImport: i0 });