@sumaris-net/ngx-components 1.22.11-rc12 → 1.22.11-rc13

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.
@@ -15009,7 +15009,9 @@
15009
15009
  return expectedProfileIndex !== -1 && PersonUtils.getMainProfileIndex(actualProfiles) <= expectedProfileIndex;
15010
15010
  };
15011
15011
  PersonUtils.personToString = function (obj) {
15012
- return obj && obj.id && (obj.lastName + ' ' + obj.firstName) || undefined;
15012
+ if (!obj || !obj.id)
15013
+ return undefined;
15014
+ return obj.lastName + ' ' + obj.firstName;
15013
15015
  };
15014
15016
  PersonUtils.personsToString = function (data, separator) {
15015
15017
  return (data || []).map(PersonUtils.personToString).join(separator || ', ');
@@ -30507,7 +30509,7 @@
30507
30509
  return total;
30508
30510
  }));
30509
30511
  };
30510
- AbstractUserEventService.prototype.listenAllChanges = function (filter, options) {
30512
+ AbstractUserEventService.prototype.listenAllChanges = function (filter, opts) {
30511
30513
  var _this = this;
30512
30514
  var _a;
30513
30515
  if (!((_a = this.subscriptions) === null || _a === void 0 ? void 0 : _a.listenAllChanges)) {
@@ -30517,13 +30519,13 @@
30517
30519
  if (!filter)
30518
30520
  filter = this.defaultFilter();
30519
30521
  filter = this.asFilter(filter);
30520
- var withContent = (options === null || options === void 0 ? void 0 : options.withContent) === true;
30522
+ var withContent = (opts === null || opts === void 0 ? void 0 : opts.withContent) === true;
30521
30523
  if (this._debug)
30522
30524
  console.debug(this._logPrefix + "[WS] Listening changes for user events with filter:", filter);
30523
30525
  return this.graphql.subscribe({
30524
30526
  query: this.subscriptions.listenAllChanges,
30525
- fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
30526
- variables: { filter: filter.asPodObject(), interval: toNumber(options === null || options === void 0 ? void 0 : options.interval, 10) },
30527
+ fetchPolicy: opts === null || opts === void 0 ? void 0 : opts.fetchPolicy,
30528
+ variables: { filter: filter.asPodObject(), interval: toNumber(opts === null || opts === void 0 ? void 0 : opts.interval, 10) },
30527
30529
  error: {
30528
30530
  code: SocialErrorCodes.SUBSCRIBE_USER_EVENTS_ERROR,
30529
30531
  message: 'SOCIAL.ERROR.SUBSCRIBE_USER_EVENTS_ERROR'
@@ -30531,22 +30533,23 @@
30531
30533
  }).pipe(operators.mergeMap(function (_b) {
30532
30534
  var data = _b.data;
30533
30535
  return __awaiter(_this, void 0, void 0, function () {
30534
- var updatedData;
30535
30536
  var _this = this;
30536
30537
  return __generator(this, function (_b) {
30537
30538
  switch (_b.label) {
30538
30539
  case 0:
30539
30540
  if (data && this._debug)
30540
30541
  console.debug(this._logPrefix + "Received new user events:", data);
30542
+ // Update cache (will update watchAll queries)
30543
+ if (isNotEmptyArray(data)) {
30544
+ this.insertIntoMutableCachedQueries(this.graphql.cache, {
30545
+ query: withContent ? this.queries.loadAllWithContent : this.queries.loadAll,
30546
+ data: data
30547
+ });
30548
+ }
30549
+ if (!(!opts || opts.toEntity !== false)) return [3 /*break*/, 2];
30541
30550
  return [4 /*yield*/, Promise.all((data || []).map(function (value) { return _this.processUserEvent(value, _this); }))];
30542
- case 1:
30543
- updatedData = _b.sent();
30544
- // Update cache
30545
- this.insertIntoMutableCachedQueries(this.graphql.cache, {
30546
- query: withContent ? this.queries.loadAllWithContent : this.queries.loadAll,
30547
- data: updatedData
30548
- });
30549
- return [2 /*return*/, updatedData];
30551
+ case 1: return [2 /*return*/, _b.sent()];
30552
+ case 2: return [2 /*return*/, data];
30550
30553
  }
30551
30554
  });
30552
30555
  });
@@ -30970,12 +30973,14 @@
30970
30973
  this.subscriptions.add(this.userEventService
30971
30974
  .watchAll(0, this.pageSize, this.sortBy, this.sortDirection, this.filter)
30972
30975
  .subscribe(function (result) {
30973
- var _a;
30976
+ var _a, _b;
30974
30977
  if (_this.debug)
30975
30978
  console.debug("[user-event-notification-list] receiving " + result.total + " user events", result.data);
30976
30979
  _this.$items.next(result.data);
30977
30980
  _this.$itemCount.next(result.total || ((_a = result.data) === null || _a === void 0 ? void 0 : _a.length) || 0);
30978
30981
  _this._fetchMoreFn = result.fetchMore;
30982
+ _this._fetchingMore = false; // Reset this marker
30983
+ (_b = _this._fetchMoreSubscription) === null || _b === void 0 ? void 0 : _b.unsubscribe();
30979
30984
  _this.markForCheck();
30980
30985
  }));
30981
30986
  // Listen changes
@@ -31019,27 +31024,27 @@
31019
31024
  UserEventNotificationList.prototype.executeAction = function (event, action, userEvent) {
31020
31025
  return __awaiter(this, void 0, void 0, function () {
31021
31026
  var res, err_1;
31022
- return __generator(this, function (_b) {
31023
- switch (_b.label) {
31027
+ return __generator(this, function (_c) {
31028
+ switch (_c.label) {
31024
31029
  case 0:
31025
31030
  if (event === null || event === void 0 ? void 0 : event.defaultPrevented)
31026
31031
  return [2 /*return*/]; // Skip if prevented
31027
31032
  // Disable default action (.e.g avoid to call click() function)
31028
31033
  if (event)
31029
31034
  event.preventDefault();
31030
- _b.label = 1;
31035
+ _c.label = 1;
31031
31036
  case 1:
31032
- _b.trys.push([1, 4, , 5]);
31037
+ _c.trys.push([1, 4, , 5]);
31033
31038
  res = action.executeAction(userEvent);
31034
31039
  this.dismiss();
31035
31040
  if (!(res instanceof Promise)) return [3 /*break*/, 3];
31036
31041
  return [4 /*yield*/, res];
31037
31042
  case 2:
31038
- _b.sent();
31039
- _b.label = 3;
31043
+ _c.sent();
31044
+ _c.label = 3;
31040
31045
  case 3: return [3 /*break*/, 5];
31041
31046
  case 4:
31042
- err_1 = _b.sent();
31047
+ err_1 = _c.sent();
31043
31048
  console.error(err_1);
31044
31049
  return [3 /*break*/, 5];
31045
31050
  case 5: return [2 /*return*/];
@@ -31054,19 +31059,19 @@
31054
31059
  var _a;
31055
31060
  return __awaiter(this, void 0, void 0, function () {
31056
31061
  var result, data, err_2;
31057
- return __generator(this, function (_b) {
31058
- switch (_b.label) {
31062
+ return __generator(this, function (_c) {
31063
+ switch (_c.label) {
31059
31064
  case 0:
31060
31065
  if (!this._fetchMoreFn || this._fetchingMore)
31061
31066
  return [2 /*return*/];
31062
31067
  console.debug('[user-event-notification-list] Fetching more notifications...', event);
31063
31068
  this._fetchingMore = true;
31064
- _b.label = 1;
31069
+ _c.label = 1;
31065
31070
  case 1:
31066
- _b.trys.push([1, 3, 4, 5]);
31071
+ _c.trys.push([1, 3, 4, 5]);
31067
31072
  return [4 /*yield*/, this._fetchMoreFn()];
31068
31073
  case 2:
31069
- result = _b.sent();
31074
+ result = _c.sent();
31070
31075
  data = __spread((this.$items.value || []), result.data);
31071
31076
  // Remove duplication (e.g. when new user event was added by subscription)
31072
31077
  data = removeDuplicatesFromArray(data, 'id');
@@ -31075,7 +31080,7 @@
31075
31080
  this._fetchMoreFn = result.fetchMore;
31076
31081
  return [3 /*break*/, 5];
31077
31082
  case 3:
31078
- err_2 = _b.sent();
31083
+ err_2 = _c.sent();
31079
31084
  console.error(err_2);
31080
31085
  this._fetchMoreFn = undefined;
31081
31086
  return [3 /*break*/, 5];
@@ -31092,18 +31097,18 @@
31092
31097
  return __awaiter(this, void 0, void 0, function () {
31093
31098
  var panel;
31094
31099
  var _this = this;
31095
- return __generator(this, function (_b) {
31096
- switch (_b.label) {
31100
+ return __generator(this, function (_c) {
31101
+ switch (_c.label) {
31097
31102
  case 0:
31098
31103
  if (this._fetchMoreSubscription)
31099
31104
  this._fetchMoreSubscription.unsubscribe();
31100
31105
  threshold = threshold || (this.mobile ? '15%' : '2%');
31101
31106
  return [4 /*yield*/, waitFor(function () { return !!_this.ionContent; })];
31102
31107
  case 1:
31103
- _b.sent();
31108
+ _c.sent();
31104
31109
  return [4 /*yield*/, this.ionContent.getScrollElement()];
31105
31110
  case 2:
31106
- panel = _b.sent();
31111
+ panel = _c.sent();
31107
31112
  // Trigger fetch more, end end scroll reached
31108
31113
  this._fetchMoreSubscription = fromScrollEndEvent(panel, threshold, 250 /*force to check when no scrollbar - e.g. in large screen*/)
31109
31114
  .subscribe(function () { return _this.fetchMore(); });