@sumaris-net/ngx-components 1.9.5 → 1.9.6

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.
@@ -13579,7 +13579,7 @@ const AccountSubscriptions = {
13579
13579
  }`
13580
13580
  };
13581
13581
  class AccountService extends BaseGraphqlService {
13582
- constructor(cryptoService, network, graphql, settings, storage, file, environment) {
13582
+ constructor(cryptoService, network, graphql, settings, storage, file, translate, toastController, environment) {
13583
13583
  super(graphql, environment);
13584
13584
  this.cryptoService = cryptoService;
13585
13585
  this.network = network;
@@ -13587,6 +13587,8 @@ class AccountService extends BaseGraphqlService {
13587
13587
  this.settings = settings;
13588
13588
  this.storage = storage;
13589
13589
  this.file = file;
13590
+ this.translate = translate;
13591
+ this.toastController = toastController;
13590
13592
  this.environment = environment;
13591
13593
  this.onLogin = new Subject();
13592
13594
  this.onLogout = new Subject();
@@ -13933,13 +13935,26 @@ class AccountService extends BaseGraphqlService {
13933
13935
  throw new Error('Cannot check account in offline mode');
13934
13936
  const now = Date.now();
13935
13937
  console.debug(`[account] Reloading account...`);
13936
- yield this.loadData();
13937
- yield this.saveLocally();
13938
- console.debug(`[account] Reloading account [OK] in ${Date.now() - now}ms`);
13939
- // Emit login event to subscribers
13940
- this.onLogin.next(this._data);
13941
- this.onChange.next(this._data);
13942
- return this._data;
13938
+ const wasLogin = this.isLogin();
13939
+ try {
13940
+ yield this.loadData();
13941
+ yield this.saveLocally();
13942
+ console.debug(`[account] Reloading account [OK] in ${Date.now() - now}ms`);
13943
+ // Emit login event to subscribers
13944
+ this.onLogin.next(this._data);
13945
+ this.onChange.next(this._data);
13946
+ return this._data;
13947
+ }
13948
+ catch (error) {
13949
+ // Cannot reload but was login: force to logout
13950
+ if (wasLogin && !this.isLogin()) {
13951
+ console.error(`[account] Reloading account failed. Will force logout...`, error);
13952
+ yield this.logout();
13953
+ }
13954
+ else {
13955
+ throw error;
13956
+ }
13957
+ }
13943
13958
  });
13944
13959
  }
13945
13960
  /**
@@ -14556,8 +14571,11 @@ class AccountService extends BaseGraphqlService {
14556
14571
  target.id = source.id || target.id;
14557
14572
  target.updateDate = source.updateDate || target.updateDate;
14558
14573
  }
14574
+ showToast(opts) {
14575
+ return Toasts.show(this.toastController, this.translate, opts);
14576
+ }
14559
14577
  }
14560
- AccountService.ɵprov = i0.ɵɵdefineInjectable({ factory: function AccountService_Factory() { return new AccountService(i0.ɵɵinject(CryptoService), i0.ɵɵinject(NetworkService), i0.ɵɵinject(GraphqlService), i0.ɵɵinject(LocalSettingsService), i0.ɵɵinject(i3$1.Storage), i0.ɵɵinject(FileService), i0.ɵɵinject(ENVIRONMENT)); }, token: AccountService, providedIn: "root" });
14578
+ AccountService.ɵprov = i0.ɵɵdefineInjectable({ factory: function AccountService_Factory() { return new AccountService(i0.ɵɵinject(CryptoService), i0.ɵɵinject(NetworkService), i0.ɵɵinject(GraphqlService), i0.ɵɵinject(LocalSettingsService), i0.ɵɵinject(i3$1.Storage), i0.ɵɵinject(FileService), i0.ɵɵinject(i1$1.TranslateService, 8), i0.ɵɵinject(i1$4.ToastController, 8), i0.ɵɵinject(ENVIRONMENT)); }, token: AccountService, providedIn: "root" });
14561
14579
  AccountService.decorators = [
14562
14580
  { type: Injectable, args: [{ providedIn: 'root' },] }
14563
14581
  ];
@@ -14568,6 +14586,8 @@ AccountService.ctorParameters = () => [
14568
14586
  { type: LocalSettingsService },
14569
14587
  { type: Storage },
14570
14588
  { type: FileService },
14589
+ { type: TranslateService, decorators: [{ type: Optional }] },
14590
+ { type: ToastController, decorators: [{ type: Optional }] },
14571
14591
  { type: undefined, decorators: [{ type: Inject, args: [ENVIRONMENT,] }] }
14572
14592
  ];
14573
14593