@sumaris-net/ngx-components 1.0.4 → 1.0.8

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.
@@ -10831,6 +10831,7 @@
10831
10831
  };
10832
10832
  LocalSettingsService.prototype.apply = function (settings, opts) {
10833
10833
  return __awaiter(this, void 0, void 0, function () {
10834
+ var data;
10834
10835
  return __generator(this, function (_a) {
10835
10836
  switch (_a.label) {
10836
10837
  case 0:
@@ -10840,7 +10841,10 @@
10840
10841
  _a.sent();
10841
10842
  _a.label = 2;
10842
10843
  case 2:
10843
- this._data = Object.assign(Object.assign({}, this._data), settings);
10844
+ data = Object.assign(Object.assign({}, this._data), settings);
10845
+ if (equals(data, this._data))
10846
+ return [2 /*return*/]; // SKip if same
10847
+ this._data = data;
10844
10848
  if (!(opts && opts.persistImmediate)) return [3 /*break*/, 4];
10845
10849
  return [4 /*yield*/, this.persistLocally(true)];
10846
10850
  case 3:
@@ -14507,7 +14511,10 @@
14507
14511
  var message = err && err.message || err;
14508
14512
  if (typeof message === 'string' && message.trim().indexOf('{"code":') === 0) {
14509
14513
  try {
14510
- error = JSON.parse(err.message);
14514
+ error = JSON.parse(message
14515
+ // Remove special characters before parsing (e.g. SQL errors from an Oracle database)
14516
+ .replace('\n', ' ')
14517
+ .replace('\r', ''));
14511
14518
  }
14512
14519
  catch (parseError) {
14513
14520
  console.error('Unable to parse error as JSON: ', parseError);
@@ -14782,7 +14789,7 @@
14782
14789
  settings: core.gql(templateObject_2$4 || (templateObject_2$4 = __makeTemplateObject(["fragment UserSettingsFragment on UserSettingsVO {\n id\n locale\n latLongFormat\n content\n nonce\n updateDate\n __typename\n }"], ["fragment UserSettingsFragment on UserSettingsVO {\n id\n locale\n latLongFormat\n content\n nonce\n updateDate\n __typename\n }"])))
14783
14790
  };
14784
14791
  // Load account query
14785
- var LoadQuery$1 = core.gql(templateObject_3$3 || (templateObject_3$3 = __makeTemplateObject(["\n query Account {\n data: account {\n ...AccountFragment\n }\n }\n ", "\n"], ["\n query Account {\n data: account {\n ...AccountFragment\n }\n }\n ", "\n"])), Fragments$1.account);
14792
+ var LoadQuery$1 = core.gql(templateObject_3$3 || (templateObject_3$3 = __makeTemplateObject(["\n query Account {\n data: account {\n ...AccountFragment\n }\n }\n ", "\n ", "\n"], ["\n query Account {\n data: account {\n ...AccountFragment\n }\n }\n ", "\n ", "\n"])), Fragments$1.account, Fragments$1.settings);
14786
14793
  // Check email query
14787
14794
  var IsEmailExistsQuery = core.gql(templateObject_4$3 || (templateObject_4$3 = __makeTemplateObject(["\n query IsEmailExists($email: String, $hash: String){\n isEmailExists(email: $email, hash: $hash)\n }\n"], ["\n query IsEmailExists($email: String, $hash: String){\n isEmailExists(email: $email, hash: $hash)\n }\n"])));
14788
14795
  // Save (create or update) account mutation
@@ -14799,7 +14806,9 @@
14799
14806
  var AuthQuery = core.gql(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n query Auth($token: String){\n authenticate(token: $token)\n }\n"], ["\n query Auth($token: String){\n authenticate(token: $token)\n }\n"])));
14800
14807
  // New auth challenge query
14801
14808
  var AuthChallengeQuery = core.gql(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n query AuthChallenge{\n authChallenge{\n challenge\n pubkey\n signature\n }\n }\n"], ["\n query AuthChallenge{\n authChallenge{\n challenge\n pubkey\n signature\n }\n }\n"])));
14802
- var UpdateSubscription = core.gql(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n subscription updateAccount($interval: Int){\n data: updateAccount(interval: $interval) {\n id\n updateDate\n }\n }\n"], ["\n subscription updateAccount($interval: Int){\n data: updateAccount(interval: $interval) {\n id\n updateDate\n }\n }\n"])));
14809
+ var AccountSubscriptions = {
14810
+ listenChanges: core.gql(templateObject_12 || (templateObject_12 = __makeTemplateObject(["subscription updateAccount($interval: Int){\n data: updateAccount(interval: $interval) {\n id\n updateDate\n }\n }"], ["subscription updateAccount($interval: Int){\n data: updateAccount(interval: $interval) {\n id\n updateDate\n }\n }"])))
14811
+ };
14803
14812
  var AccountService = /** @class */ (function (_super) {
14804
14813
  __extends(AccountService, _super);
14805
14814
  function AccountService(cryptoService, network, graphql, settings, storage, file, environment) {
@@ -15506,9 +15515,9 @@
15506
15515
  if (!this._cache.pubkey)
15507
15516
  return rxjs.Subscription.EMPTY;
15508
15517
  var self = this;
15509
- console.debug('[account] [WS] Listening account changes');
15518
+ console.debug('[account] [WS] Listening changes');
15510
15519
  var subscription = this.graphql.subscribe({
15511
- query: UpdateSubscription,
15520
+ query: AccountSubscriptions.listenChanges,
15512
15521
  variables: {
15513
15522
  interval: 10
15514
15523
  },
@@ -15817,23 +15826,23 @@
15817
15826
  };
15818
15827
  AccountService.prototype.saveLocalSettingsRemotely = function (source) {
15819
15828
  return __awaiter(this, void 0, void 0, function () {
15820
- var account, settings, hasChanges;
15829
+ var account, settings, changed;
15821
15830
  return __generator(this, function (_b) {
15822
15831
  switch (_b.label) {
15823
15832
  case 0:
15824
- if (!source || !this.isLogin())
15833
+ if (!source || !this.isLogin() || source.accountInheritance === false)
15825
15834
  return [2 /*return*/]; // Skip
15826
15835
  account = this.account;
15827
15836
  settings = exports.UserSettings.fromObject(account.settings) || new exports.UserSettings();
15828
- hasChanges = settings.merge(source, ['locale', 'latLongFormat', 'properties']);
15829
- if (!hasChanges) return [3 /*break*/, 2];
15830
- if (this._debug)
15831
- console.debug('[account] Save local settings remotely', settings);
15837
+ changed = settings.merge(source, ['locale', 'latLongFormat', 'properties']);
15838
+ if (!changed)
15839
+ return [2 /*return*/]; // Skip if unchanged
15840
+ // Save remotely
15841
+ this.account.settings = settings;
15832
15842
  return [4 /*yield*/, this.saveSettingsRemotely(settings)];
15833
15843
  case 1:
15834
15844
  _b.sent();
15835
- _b.label = 2;
15836
- case 2: return [2 /*return*/];
15845
+ return [2 /*return*/];
15837
15846
  }
15838
15847
  });
15839
15848
  });
@@ -15919,9 +15928,8 @@
15919
15928
  if (this._debug)
15920
15929
  console.debug("[account] Settings remotely saved in " + (Date.now() - now) + "ms");
15921
15930
  // Save into account
15922
- if (this.account) {
15931
+ if (this.account)
15923
15932
  this.account.settings = settings;
15924
- }
15925
15933
  return [2 /*return*/];
15926
15934
  }
15927
15935
  });