@sumaris-net/ngx-components 0.28.5 → 1.0.0

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.
Files changed (28) hide show
  1. package/bundles/sumaris-net.ngx-components.umd.js +286 -303
  2. package/bundles/sumaris-net.ngx-components.umd.js.map +1 -1
  3. package/bundles/sumaris-net.ngx-components.umd.min.js +2 -2
  4. package/bundles/sumaris-net.ngx-components.umd.min.js.map +1 -1
  5. package/doc/changelog.md +4 -0
  6. package/esm2015/src/app/core/graphql/graphql.service.js +5 -8
  7. package/esm2015/src/app/core/services/account.service.js +177 -188
  8. package/esm2015/src/app/core/services/base-entity-service.class.js +9 -7
  9. package/esm2015/src/app/core/services/base-graphql-service.class.js +7 -2
  10. package/esm2015/src/app/core/services/config.service.js +9 -54
  11. package/esm2015/src/app/core/services/model/account.model.js +1 -1
  12. package/esm2015/src/app/core/services/model/settings.model.js +29 -2
  13. package/esm2015/src/app/core/services/network.service.js +5 -7
  14. package/esm2015/src/app/core/services/storage/entities-storage.service.js +3 -6
  15. package/esm2015/src/app/shared/services/startable-service.class.js +13 -2
  16. package/fesm2015/sumaris-net.ngx-components.js +240 -261
  17. package/fesm2015/sumaris-net.ngx-components.js.map +1 -1
  18. package/package.json +1 -1
  19. package/src/app/core/graphql/graphql.service.d.ts +0 -1
  20. package/src/app/core/services/account.service.d.ts +8 -21
  21. package/src/app/core/services/base-entity-service.class.d.ts +1 -0
  22. package/src/app/core/services/base-graphql-service.class.d.ts +3 -2
  23. package/src/app/core/services/config.service.d.ts +2 -9
  24. package/src/app/core/services/model/settings.model.d.ts +2 -0
  25. package/src/app/core/services/network.service.d.ts +2 -2
  26. package/src/app/core/services/storage/entities-storage.service.d.ts +0 -1
  27. package/src/app/shared/services/startable-service.class.d.ts +3 -1
  28. package/sumaris-net.ngx-components.metadata.json +1 -1
@@ -7757,6 +7757,9 @@ class StartableService {
7757
7757
  this._startByReadyFunction = true; // should start when calling ready() ?
7758
7758
  this._data = null;
7759
7759
  this._started = false;
7760
+ this._startPromise = null;
7761
+ this._startPrerequisite = null;
7762
+ this._subscription = null;
7760
7763
  this._startPrerequisite = prerequisiteService
7761
7764
  ? () => prerequisiteService.ready()
7762
7765
  : () => Promise.resolve();
@@ -7786,6 +7789,10 @@ class StartableService {
7786
7789
  stop() {
7787
7790
  return __awaiter(this, void 0, void 0, function* () {
7788
7791
  try {
7792
+ if (this._subscription) {
7793
+ this._subscription.unsubscribe();
7794
+ this._subscription = null;
7795
+ }
7789
7796
  yield this.ngOnStop();
7790
7797
  this._started = false;
7791
7798
  this._startPromise = undefined;
@@ -7820,6 +7827,10 @@ class StartableService {
7820
7827
  return waitFor(() => this._started)
7821
7828
  .then(() => this._data);
7822
7829
  }
7830
+ registerSubscription(sub) {
7831
+ this._subscription = this._subscription || new Subscription();
7832
+ return this._subscription.add(sub);
7833
+ }
7823
7834
  ngOnStop() {
7824
7835
  return __awaiter(this, void 0, void 0, function* () {
7825
7836
  // Can be override by subclasses
@@ -10023,7 +10034,6 @@ class NetworkService extends StartableService {
10023
10034
  this.onPeerChanges = this.onStart.pipe(map(peer => peer && peer.url), filter(isNotNilOrBlank), distinctUntilChanged());
10024
10035
  this.onNetworkStatusChanges = new BehaviorSubject(null);
10025
10036
  this.onResetNetworkCache = new EventEmitter(true);
10026
- this._subscription = new Subscription();
10027
10037
  this._listeners = {};
10028
10038
  this._mobile = this.platform.is('mobile');
10029
10039
  if (this._mobile) {
@@ -10184,7 +10194,8 @@ class NetworkService extends StartableService {
10184
10194
  /**
10185
10195
  * Check if the peer is alive
10186
10196
  *
10187
- * @param email
10197
+ * @param peer
10198
+ * @param opts
10188
10199
  */
10189
10200
  checkPeerAlive(peer, opts) {
10190
10201
  return __awaiter(this, void 0, void 0, function* () {
@@ -10324,8 +10335,8 @@ class NetworkService extends StartableService {
10324
10335
  this.startRefreshTimer();
10325
10336
  // Listen for device network changes
10326
10337
  if (this.network) {
10327
- this._subscription.add(this.network.onDisconnect().subscribe(() => this.onDeviceConnectionChanged('none')));
10328
- this._subscription.add(this.network.onConnect().subscribe(() => this.onDeviceConnectionChanged(this.network.type)));
10338
+ this.registerSubscription(this.network.onDisconnect().subscribe(() => this.onDeviceConnectionChanged('none')));
10339
+ this.registerSubscription(this.network.onConnect().subscribe(() => this.onDeviceConnectionChanged(this.network.type)));
10329
10340
  }
10330
10341
  });
10331
10342
  }
@@ -10336,8 +10347,6 @@ class NetworkService extends StartableService {
10336
10347
  if (this._timerRefreshCondition() === false) {
10337
10348
  this.stopRefreshTimer();
10338
10349
  }
10339
- this._subscription.unsubscribe();
10340
- this._subscription = new Subscription();
10341
10350
  });
10342
10351
  }
10343
10352
  /**
@@ -11032,7 +11041,6 @@ class EntitiesStorage extends StartableService {
11032
11041
  this.progressBarService = progressBarService;
11033
11042
  this.storage = storage;
11034
11043
  this.environment = environment;
11035
- this._subscription = new Subscription();
11036
11044
  this._$save = new EventEmitter(true);
11037
11045
  this._dirty = false;
11038
11046
  this._saving = false;
@@ -11325,7 +11333,7 @@ class EntitiesStorage extends StartableService {
11325
11333
  // Restore sequences
11326
11334
  yield this.restoreLocally();
11327
11335
  // Start a save timer
11328
- this._subscription.add(merge(this._$save, timer(this._saveTimerPeriod, this._saveTimerPeriod))
11336
+ this.registerSubscription(merge(this._$save, timer(this._saveTimerPeriod, this._saveTimerPeriod))
11329
11337
  .pipe(
11330
11338
  // Avoid to many call (e.g. when $save AND timer are triggered
11331
11339
  throttleTime(this._saveTimerPeriod))
@@ -11336,8 +11344,6 @@ class EntitiesStorage extends StartableService {
11336
11344
  }
11337
11345
  ngOnStop() {
11338
11346
  return __awaiter(this, void 0, void 0, function* () {
11339
- this._subscription.unsubscribe();
11340
- this._subscription = new Subscription();
11341
11347
  if (this.dirty) {
11342
11348
  yield this.storeLocally();
11343
11349
  }
@@ -11519,7 +11525,34 @@ let UserSettings = UserSettings_1 = class UserSettings extends Entity {
11519
11525
  }
11520
11526
  this.nonce = source.nonce;
11521
11527
  }
11528
+ merge(source, includesProperties) {
11529
+ if (!source)
11530
+ return; // Skip
11531
+ // Reset content
11532
+ this.content = {};
11533
+ let hasChanges = false;
11534
+ // For each property of source object
11535
+ Object.keys(source)
11536
+ .forEach(key => {
11537
+ // If property exists in UserSettings class: store it directly
11538
+ if (UserSettings_1.SETTINGS_PROPERTIES.includes(key)) {
11539
+ if (!equals(this[key], source[key])) {
11540
+ this[key] = source[key];
11541
+ hasChanges = true;
11542
+ }
11543
+ }
11544
+ // Else, store property into the 'content' map
11545
+ else if (includesProperties && includesProperties.includes(key)) {
11546
+ if (!equals(this.content[key], source[key])) {
11547
+ this.content[key] = Object.assign({}, source[key]);
11548
+ hasChanges = true;
11549
+ }
11550
+ }
11551
+ });
11552
+ return hasChanges;
11553
+ }
11522
11554
  };
11555
+ UserSettings.SETTINGS_PROPERTIES = ['locale', 'latLongFormat'];
11523
11556
  UserSettings = UserSettings_1 = __decorate([
11524
11557
  EntityClass({ typename: 'UserSettingsVO' })
11525
11558
  ], UserSettings);
@@ -11932,7 +11965,6 @@ class GraphqlService extends StartableService {
11932
11965
  this.cryptoService = cryptoService;
11933
11966
  this.environment = environment;
11934
11967
  this.typePolicies = typePolicies;
11935
- this._subscription = new Subscription();
11936
11968
  this.connectionParams = {};
11937
11969
  this.onNetworkError = new Subject();
11938
11970
  this.customErrors = {};
@@ -12432,7 +12464,7 @@ class GraphqlService extends StartableService {
12432
12464
  });
12433
12465
  // Creating a mutation queue
12434
12466
  const queueLink = new QueueLink();
12435
- this._subscription.add(this._networkStatusChanged$
12467
+ this.registerSubscription(this._networkStatusChanged$
12436
12468
  .subscribe(type => {
12437
12469
  // Network is offline: start buffering into queue
12438
12470
  if (type === 'none') {
@@ -12495,9 +12527,9 @@ class GraphqlService extends StartableService {
12495
12527
  }
12496
12528
  }
12497
12529
  // Listen for network restart
12498
- this._subscription.add(this.network.on('start', () => this.restart()));
12530
+ this.registerSubscription(this.network.on('start', () => this.restart()));
12499
12531
  // Listen for clear cache request, from network
12500
- this._subscription.add(this.network.on('resetCache', () => this.clearCache()));
12532
+ this.registerSubscription(this.network.on('resetCache', () => this.clearCache()));
12501
12533
  console.info('[graphql] Starting graphql [OK]');
12502
12534
  return client;
12503
12535
  });
@@ -12505,8 +12537,6 @@ class GraphqlService extends StartableService {
12505
12537
  ngOnStop() {
12506
12538
  return __awaiter(this, void 0, void 0, function* () {
12507
12539
  console.info('[graphql] Stopping graphql service...');
12508
- this._subscription.unsubscribe();
12509
- this._subscription = new Subscription();
12510
12540
  yield this.resetClient();
12511
12541
  });
12512
12542
  }
@@ -12625,8 +12655,9 @@ const sha256 = require('hash.js/lib/hash/sha/256');
12625
12655
  class BaseGraphqlServiceOptions {
12626
12656
  }
12627
12657
  // eslint-disable-next-line @angular-eslint/directive-class-suffix
12628
- class BaseGraphqlService {
12658
+ class BaseGraphqlService extends StartableService {
12629
12659
  constructor(graphql, options) {
12660
+ super(graphql);
12630
12661
  this.graphql = graphql;
12631
12662
  this._mutableWatchQueries = [];
12632
12663
  // Max updated queries, for this entity.
@@ -12818,6 +12849,9 @@ class BaseGraphqlService {
12818
12849
  return { query, variables };
12819
12850
  });
12820
12851
  }
12852
+ ngOnStart() {
12853
+ return Promise.resolve(null);
12854
+ }
12821
12855
  }
12822
12856
  BaseGraphqlService.decorators = [
12823
12857
  { type: Directive }
@@ -12951,18 +12985,16 @@ class AccountService extends BaseGraphqlService {
12951
12985
  this.onChange = new Subject();
12952
12986
  this.onAuthTokenChange = new Subject();
12953
12987
  this.onAuthBasicChange = new Subject();
12954
- this._data = {
12988
+ this._cache = {
12955
12989
  loaded: false,
12956
12990
  keypair: null,
12957
12991
  authToken: null,
12958
12992
  authBasic: null,
12959
12993
  pubkey: null,
12960
12994
  mainProfile: null,
12961
- account: null,
12962
12995
  person: null,
12963
12996
  department: null
12964
12997
  };
12965
- this._started = false;
12966
12998
  this._$additionalFields = new BehaviorSubject([]);
12967
12999
  this._tokenType$ = new BehaviorSubject(undefined);
12968
13000
  this._debug = !environment.production;
@@ -12972,41 +13004,31 @@ class AccountService extends BaseGraphqlService {
12972
13004
  // Send auth token to the graphql layer, when changed
12973
13005
  this.onAuthTokenChange.subscribe((token) => this.graphql.setAuthToken(token));
12974
13006
  this.onAuthBasicChange.subscribe((basic) => this.graphql.setAuthBasic(basic));
12975
- // Listen graphql start (or restart)
12976
- this.graphql.onStart.subscribe(() => __awaiter(this, void 0, void 0, function* () {
12977
- if (!this._started) {
12978
- this.ready();
12979
- }
12980
- if (this._started && this.isLogin()) {
12981
- console.debug('[account] Restarting, to retry to authenticate...');
12982
- this.restart();
12983
- }
12984
- }));
12985
13007
  // Force network to wait account service, after getting connection to the peer
12986
13008
  this.network.on('beforeTryOnlineFinish', (online) => __awaiter(this, void 0, void 0, function* () {
12987
13009
  // If online, wait a full restart, because it can force offline mode
12988
- if (online && (!this._started || this.isLogin())) {
12989
- console.debug('[account] Force networkService.tryOnline() to wait, that account service is restarted...');
12990
- //await this.stop();
12991
- yield sleep(500);
12992
- return this.ready();
13010
+ if (online && (!this.started || this.isLogin())) {
13011
+ console.debug('[account] Force networkService.tryOnline() to wait, that graphql and account service is restarted...');
13012
+ yield sleep(500); // wait graphql service to be restarted
13013
+ if (!this.started)
13014
+ yield this.ready();
12993
13015
  }
12994
13016
  }));
12995
13017
  }
12996
13018
  get account() {
12997
- return this._data.loaded ? this._data.account : undefined;
13019
+ return this._cache.loaded ? this._data : undefined;
12998
13020
  }
12999
13021
  get person() {
13000
- if (this._data.loaded && !this._data.person) {
13001
- this._data.person = this._data.loaded ? this._data.account.asPerson() : undefined;
13022
+ if (this._cache.loaded && !this._cache.person) {
13023
+ this._cache.person = this._cache.loaded ? this._data.asPerson() : undefined;
13002
13024
  }
13003
- return this._data.person;
13025
+ return this._cache.person;
13004
13026
  }
13005
13027
  get department() {
13006
- if (this._data.loaded && !this._data.department) {
13007
- this._data.department = this._data.loaded ? this._data.account.asPerson().department : undefined;
13028
+ if (this._cache.loaded && !this._cache.department) {
13029
+ this._cache.department = this._cache.loaded ? this._data.asPerson().department : undefined;
13008
13030
  }
13009
- return this._data.department;
13031
+ return this._cache.department;
13010
13032
  }
13011
13033
  get tokenType() {
13012
13034
  return this._tokenType$.value;
@@ -13016,91 +13038,73 @@ class AccountService extends BaseGraphqlService {
13016
13038
  console.info('[account] Using authentication token type: ' + value);
13017
13039
  this._tokenType$.next(value);
13018
13040
  // Reset values
13019
- this._data.authToken = undefined;
13041
+ this._cache.authToken = undefined;
13020
13042
  this.onAuthTokenChange.next(undefined);
13021
- this._data.authBasic = undefined;
13043
+ this._cache.authBasic = undefined;
13022
13044
  this.onAuthBasicChange.next(undefined);
13023
13045
  }
13024
13046
  }
13025
- start() {
13026
- if (this._startPromise)
13027
- return this._startPromise;
13028
- if (this._started)
13029
- return Promise.resolve(this.account);
13030
- // Restoring local settings
13031
- this._startPromise = Promise.all([
13032
- this.settings.ready(),
13033
- // Wait token type to be set
13034
- firstNotNilPromise(this._tokenType$)
13035
- ])
13036
- .then(() => this.restoreLocally())
13037
- .then(() => {
13038
- this._started = true;
13039
- this._startPromise = undefined;
13040
- return this.account;
13041
- });
13042
- return this._startPromise;
13043
- }
13044
- get started() {
13045
- return this._started;
13046
- }
13047
- stop() {
13047
+ ngOnStart() {
13048
13048
  return __awaiter(this, void 0, void 0, function* () {
13049
- if (this._started || this._startPromise) {
13050
- this._started = false;
13051
- this._startPromise = undefined;
13052
- const hadAuthToken = this._data.authToken && true;
13053
- const hadAuthBasic = this._data.authBasic && true;
13054
- const hadAuth = hadAuthToken || hadAuthBasic;
13055
- this.resetData();
13056
- if (hadAuth) {
13057
- this.onLogout.next();
13058
- this.onChange.next(undefined);
13059
- if (hadAuthToken)
13060
- this.onAuthTokenChange.next(undefined);
13061
- if (hadAuthBasic)
13062
- this.onAuthBasicChange.next(undefined);
13049
+ yield Promise.all([
13050
+ this.settings.ready(),
13051
+ // Wait token type to be set
13052
+ firstNotNilPromise(this._tokenType$)
13053
+ ]);
13054
+ // Listen graphql start (or restart)
13055
+ this.registerSubscription(this.graphql.onStart.subscribe(() => {
13056
+ if (this.started && this.isLogin()) {
13057
+ console.debug('[account] Restarting, to retry to authenticate...');
13058
+ this.restart();
13063
13059
  }
13064
- }
13060
+ }));
13061
+ yield this.restoreLocally();
13062
+ yield this.listenSettings();
13063
+ return this._data;
13065
13064
  });
13066
13065
  }
13067
- restart() {
13066
+ ngOnStop() {
13068
13067
  return __awaiter(this, void 0, void 0, function* () {
13069
- yield this.stop();
13070
- return this.start();
13068
+ const hadAuthToken = this._cache.authToken && true;
13069
+ const hadAuthBasic = this._cache.authBasic && true;
13070
+ const hadAuth = hadAuthToken || hadAuthBasic;
13071
+ this.resetData();
13072
+ if (hadAuth) {
13073
+ this.onLogout.next();
13074
+ this.onChange.next(undefined);
13075
+ if (hadAuthToken)
13076
+ this.onAuthTokenChange.next(undefined);
13077
+ if (hadAuthBasic)
13078
+ this.onAuthBasicChange.next(undefined);
13079
+ }
13071
13080
  });
13072
13081
  }
13073
- ready() {
13074
- if (this._started)
13075
- return Promise.resolve(this.account);
13076
- return this.start();
13077
- }
13078
13082
  isLogin() {
13079
- return !!(this._data.pubkey && this._data.loaded);
13083
+ return !!(this._cache.pubkey && this._cache.loaded);
13080
13084
  }
13081
13085
  isAuth() {
13082
- return !!(this._data.pubkey && this._data.keypair && this._data.keypair.secretKey);
13086
+ return !!(this._cache.pubkey && this._cache.keypair && this._cache.keypair.secretKey);
13083
13087
  }
13084
13088
  hasMinProfile(userProfile) {
13085
13089
  // should be login, and status ENABLE or TEMPORARY
13086
- if (!this._data.account || !this._data.account.pubkey ||
13087
- (this._data.account.statusId !== StatusIds.ENABLE && this._data.account.statusId !== StatusIds.TEMPORARY)) {
13090
+ if (!this._data || !this._data.pubkey ||
13091
+ (this._data.statusId !== StatusIds.ENABLE && this._data.statusId !== StatusIds.TEMPORARY)) {
13088
13092
  return false;
13089
13093
  }
13090
- return PersonUtils.hasUpperOrEqualsProfile(this._data.account.profiles, userProfile);
13094
+ return PersonUtils.hasUpperOrEqualsProfile(this._data.profiles, userProfile);
13091
13095
  }
13092
13096
  hasExactProfile(label) {
13093
13097
  // should be login, and status ENABLE or TEMPORARY
13094
- if (!this._data.account || !this._data.account.pubkey ||
13095
- (this._data.account.statusId !== StatusIds.ENABLE && this._data.account.statusId !== StatusIds.TEMPORARY))
13098
+ if (!this._data || !this._data.pubkey ||
13099
+ (this._data.statusId !== StatusIds.ENABLE && this._data.statusId !== StatusIds.TEMPORARY))
13096
13100
  return false;
13097
- return this._data.account.profiles.some(profile => profile === label);
13101
+ return this._data.profiles.some(profile => profile === label);
13098
13102
  }
13099
13103
  hasProfileAndIsEnable(userProfile) {
13100
13104
  // should be login, and status ENABLE
13101
- if (!this._data.account || !this._data.account.pubkey || this._data.account.statusId !== StatusIds.ENABLE)
13105
+ if (!this._data || !this._data.pubkey || this._data.statusId !== StatusIds.ENABLE)
13102
13106
  return false;
13103
- return PersonUtils.hasUpperOrEqualsProfile(this._data.account.profiles, userProfile);
13107
+ return PersonUtils.hasUpperOrEqualsProfile(this._data.profiles, userProfile);
13104
13108
  }
13105
13109
  isAdmin() {
13106
13110
  return this.hasProfileAndIsEnable('ADMIN');
@@ -13120,11 +13124,11 @@ class AccountService extends BaseGraphqlService {
13120
13124
  }
13121
13125
  isOnlyGuest() {
13122
13126
  // Should be login, and status ENABLE or TEMPORARY
13123
- if (!this._data.account || !this._data.account.pubkey ||
13124
- (this._data.account.statusId !== StatusIds.ENABLE && this._data.account.statusId !== StatusIds.TEMPORARY))
13127
+ if (!this._data || !this._data.pubkey ||
13128
+ (this._data.statusId !== StatusIds.ENABLE && this._data.statusId !== StatusIds.TEMPORARY))
13125
13129
  return false;
13126
13130
  // Profile less then user
13127
- return !PersonUtils.hasUpperOrEqualsProfile(this._data.account.profiles, 'USER');
13131
+ return !PersonUtils.hasUpperOrEqualsProfile(this._data.profiles, 'USER');
13128
13132
  }
13129
13133
  canUserWriteDataForDepartment(recorderDepartment) {
13130
13134
  if (ReferentialUtils.isEmpty(recorderDepartment)) {
@@ -13133,17 +13137,17 @@ class AccountService extends BaseGraphqlService {
13133
13137
  return this.isAdmin();
13134
13138
  }
13135
13139
  // Should be login, and status ENABLE
13136
- if (!this._data.account || !this._data.account.pubkey || this._data.account.statusId !== StatusIds.ENABLE)
13140
+ if (!this._data || !this._data.pubkey || this._data.statusId !== StatusIds.ENABLE)
13137
13141
  return false;
13138
- if (!this._data.account.department || !this._data.account.department.id) {
13142
+ if (!this._data.department || !this._data.department.id) {
13139
13143
  console.warn('User account has no department ! Unable to check write right against recorderDepartment');
13140
13144
  return false;
13141
13145
  }
13142
13146
  // Same recorder department: OK, user can write
13143
- if (this._data.account.department.id === recorderDepartment.id)
13147
+ if (this._data.department.id === recorderDepartment.id)
13144
13148
  return true;
13145
13149
  // Else, check if supervisor (or more)
13146
- return PersonUtils.hasUpperOrEqualsProfile(this._data.account.profiles, 'SUPERVISOR');
13150
+ return PersonUtils.hasUpperOrEqualsProfile(this._data.profiles, 'SUPERVISOR');
13147
13151
  }
13148
13152
  register(data) {
13149
13153
  return __awaiter(this, void 0, void 0, function* () {
@@ -13154,7 +13158,7 @@ class AccountService extends BaseGraphqlService {
13154
13158
  throw new Error('Missing required username or password');
13155
13159
  if (this._debug)
13156
13160
  console.debug('[account] Register new user account...', data.account);
13157
- this._data.loaded = false;
13161
+ this._cache.loaded = false;
13158
13162
  const now = Date.now();
13159
13163
  try {
13160
13164
  const keypair = yield this.cryptoService.scryptKeypair(data.username, data.password);
@@ -13164,22 +13168,22 @@ class AccountService extends BaseGraphqlService {
13164
13168
  data.account.settings.locale = this.settings.locale;
13165
13169
  data.account.settings.latLongFormat = this.settings.latLongFormat;
13166
13170
  data.account.department.id = data.account.department.id || this.environment.defaultDepartmentId;
13167
- this._data.keypair = keypair;
13171
+ this._cache.keypair = keypair;
13168
13172
  const account = yield this.saveRemotely(data.account, keypair);
13169
13173
  // Default values
13170
13174
  account.avatar = account.avatar || (this.environment.baseUrl + DEFAULT_AVATAR_IMAGE);
13171
- this._data.mainProfile = PersonUtils.getMainProfile(account.profiles);
13172
- this._data.account = account;
13173
- this._data.pubkey = account.pubkey;
13175
+ this._cache.mainProfile = PersonUtils.getMainProfile(account.profiles);
13176
+ this._data = account;
13177
+ this._cache.pubkey = account.pubkey;
13174
13178
  // Try to auth on pod
13175
13179
  yield this.authenticate(data);
13176
- this._data.loaded = true;
13180
+ this._cache.loaded = true;
13177
13181
  yield this.saveLocally();
13178
13182
  console.debug(`[account] Account successfully registered in ${Date.now() - now}ms`);
13179
13183
  // Emit events
13180
- this.onLogin.next(this._data.account);
13181
- this.onChange.next(this._data.account);
13182
- return this._data.account;
13184
+ this.onLogin.next(this._data);
13185
+ this.onChange.next(this._data);
13186
+ return this._data;
13183
13187
  }
13184
13188
  catch (error) {
13185
13189
  console.error(error && error.message || error);
@@ -13195,20 +13199,20 @@ class AccountService extends BaseGraphqlService {
13195
13199
  // Basic auth
13196
13200
  if (tokenType === 'basic' || tokenType === 'basic-and-token') {
13197
13201
  // Generate the authBasic, if used
13198
- if (!this._data.authBasic) {
13202
+ if (!this._cache.authBasic) {
13199
13203
  // Skip if token already provided
13200
- if (!(this._data.authToken && tokenType === 'basic-and-token')) {
13204
+ if (!(this._cache.authToken && tokenType === 'basic-and-token')) {
13201
13205
  if (!data || !data.username || !data.password)
13202
13206
  throw new Error('Missing username and password');
13203
- this._data.authBasic = this.cryptoService.encodeBase64(`${data.username}:${data.password}`);
13207
+ this._cache.authBasic = this.cryptoService.encodeBase64(`${data.username}:${data.password}`);
13204
13208
  }
13205
13209
  }
13206
- this.onAuthBasicChange.next(this._data.authBasic);
13210
+ this.onAuthBasicChange.next(this._cache.authBasic);
13207
13211
  }
13208
13212
  // Generate the authToken, if used
13209
13213
  if (tokenType === 'token' || tokenType === 'basic-and-token') {
13210
13214
  try {
13211
- this._data.authToken = yield this.authenticateAndGetToken(this._data.authToken);
13215
+ this._cache.authToken = yield this.authenticateAndGetToken(this._cache.authToken);
13212
13216
  }
13213
13217
  catch (error) {
13214
13218
  // Never authenticate, or not ready for offline mode => exit
@@ -13219,7 +13223,7 @@ class AccountService extends BaseGraphqlService {
13219
13223
  }
13220
13224
  // Forget authBasic, to switch to authToken
13221
13225
  if (tokenType === 'basic-and-token') {
13222
- this._data.authBasic = undefined;
13226
+ this._cache.authBasic = undefined;
13223
13227
  this.onAuthBasicChange.next(undefined);
13224
13228
  }
13225
13229
  });
@@ -13239,18 +13243,18 @@ class AccountService extends BaseGraphqlService {
13239
13243
  throw { code: ErrorCodes$2.UNKNOWN_ERROR, message: 'ERROR.SCRYPT_ERROR' };
13240
13244
  }
13241
13245
  // Store pubkey+keypair
13242
- this._data.pubkey = Base58.encode(keypair.publicKey);
13243
- this._data.keypair = keypair;
13246
+ this._cache.pubkey = Base58.encode(keypair.publicKey);
13247
+ this._cache.keypair = keypair;
13244
13248
  // Try to load previous token
13245
13249
  let previousToken = yield this.storage.get(TOKEN_STORAGE_KEY);
13246
- previousToken = previousToken && previousToken.startsWith(this._data.pubkey) && previousToken || null;
13250
+ previousToken = previousToken && previousToken.startsWith(this._cache.pubkey) && previousToken || null;
13247
13251
  // Offline mode
13248
13252
  const offline = this.settings.hasOfflineFeature() && (this.network.offline || data.offline === true);
13249
13253
  if (offline) {
13250
- this._data.authToken = previousToken;
13254
+ this._cache.authToken = previousToken;
13251
13255
  // Make sure network if set as offline
13252
13256
  this.network.setForceOffline(true, { showToast: false });
13253
- console.info(`[account] Login [OK] {pubkey: ${this._data.pubkey.substr(0, 8)}}, {offline: true}`);
13257
+ console.info(`[account] Login [OK] {pubkey: ${this._cache.pubkey.substr(0, 8)}}, {offline: true}`);
13254
13258
  }
13255
13259
  // Online mode: try to auth on pod
13256
13260
  else {
@@ -13300,14 +13304,14 @@ class AccountService extends BaseGraphqlService {
13300
13304
  throw error;
13301
13305
  }
13302
13306
  // Emit event to observers
13303
- this.onLogin.next(this._data.account);
13304
- this.onChange.next(this._data.account);
13305
- return this._data.account;
13307
+ this.onLogin.next(this._data);
13308
+ this.onChange.next(this._data);
13309
+ return this._data;
13306
13310
  });
13307
13311
  }
13308
13312
  refresh() {
13309
13313
  return __awaiter(this, void 0, void 0, function* () {
13310
- if (!this._data.pubkey)
13314
+ if (!this._cache.pubkey)
13311
13315
  throw new Error('User not logged');
13312
13316
  if (this.network.offline)
13313
13317
  throw new Error('Cannot check account in offline mode');
@@ -13315,9 +13319,9 @@ class AccountService extends BaseGraphqlService {
13315
13319
  yield this.saveLocally();
13316
13320
  console.debug('[account] Successfully reload account');
13317
13321
  // Emit login event to subscribers
13318
- this.onLogin.next(this._data.account);
13319
- this.onChange.next(this._data.account);
13320
- return this._data.account;
13322
+ this.onLogin.next(this._data);
13323
+ this.onChange.next(this._data);
13324
+ return this._data;
13321
13325
  });
13322
13326
  }
13323
13327
  /**
@@ -13327,29 +13331,29 @@ class AccountService extends BaseGraphqlService {
13327
13331
  */
13328
13332
  save(account) {
13329
13333
  return __awaiter(this, void 0, void 0, function* () {
13330
- if (!this._data.pubkey)
13334
+ if (!this._cache.pubkey)
13331
13335
  return Promise.reject('User not logged');
13332
- if (this._data.pubkey !== account.pubkey)
13336
+ if (this._cache.pubkey !== account.pubkey)
13333
13337
  return Promise.reject('Not user account');
13334
- account = yield this.saveRemotely(account, this._data.keypair);
13338
+ account = yield this.saveRemotely(account, this._cache.keypair);
13335
13339
  // Set defaults
13336
13340
  account.avatar = account.avatar || (this.environment.baseUrl + DEFAULT_AVATAR_IMAGE);
13337
- this._data.mainProfile = PersonUtils.getMainProfile(account.profiles);
13338
- this._data.account = account;
13339
- this._data.loaded = true;
13341
+ this._cache.mainProfile = PersonUtils.getMainProfile(account.profiles);
13342
+ this._data = account;
13343
+ this._cache.loaded = true;
13340
13344
  // Save locally (in storage)
13341
13345
  yield this.saveLocally();
13342
13346
  // Send event
13343
- this.onLogin.next(this._data.account);
13344
- this.onChange.next(this._data.account);
13345
- return this._data.account;
13347
+ this.onLogin.next(this._data);
13348
+ this.onChange.next(this._data);
13349
+ return this._data;
13346
13350
  });
13347
13351
  }
13348
13352
  logout() {
13349
13353
  return __awaiter(this, void 0, void 0, function* () {
13350
- const hadAuthToken = this._data.authToken && true;
13351
- const hadAuthBasic = this._data.authBasic && true;
13352
- const pubkey = this._data && this._data.pubkey;
13354
+ const hadAuthToken = this._cache.authToken && true;
13355
+ const hadAuthBasic = this._cache.authBasic && true;
13356
+ const pubkey = this._cache && this._cache.pubkey;
13353
13357
  this.resetData();
13354
13358
  if (!this.settings.hasOfflineFeature()) {
13355
13359
  // Remove all data from the local storage
@@ -13402,9 +13406,9 @@ class AccountService extends BaseGraphqlService {
13402
13406
  if (offline) {
13403
13407
  json = yield this.storage.get(ACCOUNT_STORAGE_KEY);
13404
13408
  json = json && (typeof json === 'string') && JSON.parse(json) || json;
13405
- json = json && this._data.pubkey && (json.pubkey === this._data.pubkey) && json || null;
13406
- if (!json && this._data.pubkey) {
13407
- json = yield this.storage.get(ACCOUNT_STORAGE_KEY + '#' + this._data.pubkey);
13409
+ json = json && this._cache.pubkey && (json.pubkey === this._cache.pubkey) && json || null;
13410
+ if (!json && this._cache.pubkey) {
13411
+ json = yield this.storage.get(ACCOUNT_STORAGE_KEY + '#' + this._cache.pubkey);
13408
13412
  json = json && (typeof json === 'string') && JSON.parse(json) || json;
13409
13413
  }
13410
13414
  }
@@ -13499,7 +13503,7 @@ class AccountService extends BaseGraphqlService {
13499
13503
  });
13500
13504
  }
13501
13505
  listenChanges() {
13502
- if (!this._data.pubkey)
13506
+ if (!this._cache.pubkey)
13503
13507
  return Subscription.EMPTY;
13504
13508
  const self = this;
13505
13509
  console.debug('[account] [WS] Listening account changes');
@@ -13517,7 +13521,7 @@ class AccountService extends BaseGraphqlService {
13517
13521
  var _a;
13518
13522
  if (!data)
13519
13523
  return;
13520
- const existingUpdateDate = toDateISOString((_a = self._data.account) === null || _a === void 0 ? void 0 : _a.updateDate);
13524
+ const existingUpdateDate = toDateISOString((_a = self._data) === null || _a === void 0 ? void 0 : _a.updateDate);
13521
13525
  if (existingUpdateDate !== data.updateDate) {
13522
13526
  console.debug(`[account] [WS] Detected update on {${data.updateDate}}`);
13523
13527
  yield self.refresh();
@@ -13544,20 +13548,6 @@ class AccountService extends BaseGraphqlService {
13544
13548
  subscription.add(() => console.debug('[account] [WS] Stop listening account changes'));
13545
13549
  return subscription;
13546
13550
  }
13547
- /**
13548
- * @deprecated
13549
- */
13550
- getPageSettings(pageId, propertyName) {
13551
- return this.settings.getPageSettings(pageId, propertyName);
13552
- }
13553
- /**
13554
- * @deprecated
13555
- */
13556
- savePageSetting(pageId, value, propertyName) {
13557
- return __awaiter(this, void 0, void 0, function* () {
13558
- yield this.settings.savePageSetting(pageId, value, propertyName);
13559
- });
13560
- }
13561
13551
  get additionalFields() {
13562
13552
  return this._$additionalFields.getValue();
13563
13553
  }
@@ -13578,21 +13568,21 @@ class AccountService extends BaseGraphqlService {
13578
13568
  }
13579
13569
  /* -- protected method -- */
13580
13570
  resetData() {
13581
- this._data.loaded = false;
13582
- this._data.keypair = null;
13583
- this._data.authToken = null;
13584
- this._data.authBasic = null;
13585
- this._data.pubkey = null;
13586
- this._data.mainProfile = null;
13587
- this._data.account = new Account();
13588
- this._data.person = null;
13589
- this._data.department = null;
13571
+ this._cache.loaded = false;
13572
+ this._cache.keypair = null;
13573
+ this._cache.authToken = null;
13574
+ this._cache.authBasic = null;
13575
+ this._cache.pubkey = null;
13576
+ this._cache.mainProfile = null;
13577
+ this._cache.person = null;
13578
+ this._cache.department = null;
13579
+ this._data = new Account();
13590
13580
  }
13591
13581
  loadData(opts) {
13592
13582
  return __awaiter(this, void 0, void 0, function* () {
13593
- if (!this._data.pubkey)
13583
+ if (!this._cache.pubkey)
13594
13584
  throw new Error('User not logged');
13595
- this._data.loaded = false;
13585
+ this._cache.loaded = false;
13596
13586
  try {
13597
13587
  const account = (yield this.load(opts)) || new Account();
13598
13588
  // Set defaults
@@ -13600,17 +13590,25 @@ class AccountService extends BaseGraphqlService {
13600
13590
  account.settings = account.settings || new UserSettings();
13601
13591
  account.settings.locale = account.settings.locale || this.settings.locale;
13602
13592
  account.settings.latLongFormat = account.settings.latLongFormat || this.settings.latLongFormat || 'DDMM';
13593
+ account.settings.content = account.settings.content || {};
13603
13594
  // Read main profile
13604
- this._data.mainProfile = PersonUtils.getMainProfile(account.profiles);
13595
+ this._cache.mainProfile = PersonUtils.getMainProfile(account.profiles);
13605
13596
  // Update, instead of replace it
13606
- if (this._data.account) {
13607
- this._data.account.fromObject(account);
13597
+ if (this._data) {
13598
+ this._data.fromObject(account);
13608
13599
  }
13609
13600
  else {
13610
- this._data.account = account;
13601
+ this._data = account;
13611
13602
  }
13612
- this._data.loaded = true;
13613
- return this._data.account;
13603
+ this._cache.loaded = true;
13604
+ // Apply settings properties, found in remote settings
13605
+ const accountSettingsContentKeys = Object.keys(account.settings.content);
13606
+ if (isNotEmptyArray(accountSettingsContentKeys)) {
13607
+ const settings = Object.assign(Object.assign(Object.assign({}, this.settings.settings), account.settings.content), account.settings);
13608
+ delete settings.content; // Remove content attribute
13609
+ yield this.settings.apply(settings);
13610
+ }
13611
+ return this._data;
13614
13612
  }
13615
13613
  catch (error) {
13616
13614
  this.resetData();
@@ -13624,6 +13622,14 @@ class AccountService extends BaseGraphqlService {
13624
13622
  }
13625
13623
  });
13626
13624
  }
13625
+ listenSettings() {
13626
+ return __awaiter(this, void 0, void 0, function* () {
13627
+ // When settings changed: save it remotely
13628
+ this.registerSubscription(this.settings.onChange
13629
+ .pipe(debounceTime(1000), filter(() => this.isLogin() && this.network.online))
13630
+ .subscribe(settings => this.saveLocalSettingsRemotely(settings)));
13631
+ });
13632
+ }
13627
13633
  restoreLocally() {
13628
13634
  return __awaiter(this, void 0, void 0, function* () {
13629
13635
  // Restore from storage
@@ -13644,9 +13650,9 @@ class AccountService extends BaseGraphqlService {
13644
13650
  return;
13645
13651
  if (this._debug)
13646
13652
  console.debug(`[account] Account restoration...`);
13647
- this._data.authToken = token;
13648
- this._data.pubkey = pubkey;
13649
- this._data.keypair = seckey && {
13653
+ this._cache.authToken = token;
13654
+ this._cache.pubkey = pubkey;
13655
+ this._cache.keypair = seckey && {
13650
13656
  publicKey: Base58.decode(pubkey),
13651
13657
  secretKey: Base58.decode(seckey)
13652
13658
  } || null;
@@ -13654,7 +13660,7 @@ class AccountService extends BaseGraphqlService {
13654
13660
  if (this.network.online) {
13655
13661
  try {
13656
13662
  yield this.authenticate();
13657
- if (!this._data.authToken && !this._data.authBasic)
13663
+ if (!this._cache.authToken && !this._cache.authBasic)
13658
13664
  throw new Error('Authentication failed');
13659
13665
  }
13660
13666
  catch (error) {
@@ -13685,14 +13691,14 @@ class AccountService extends BaseGraphqlService {
13685
13691
  // Transform to entity
13686
13692
  const account = Account.fromObject(jsonAccount);
13687
13693
  // Update data
13688
- this._data.account = account;
13689
- this._data.mainProfile = PersonUtils.getMainProfile(account.profiles);
13690
- this._data.loaded = true;
13694
+ this._data = account;
13695
+ this._cache.mainProfile = PersonUtils.getMainProfile(account.profiles);
13696
+ this._cache.loaded = true;
13691
13697
  // Emit event
13692
- this.onLogin.next(this._data.account);
13693
- this.onChange.next(this._data.account);
13698
+ this.onLogin.next(this._data);
13699
+ this.onChange.next(this._data);
13694
13700
  if (this._debug)
13695
- console.debug(`[account] Account restoration [OK] {pubkey: ${pubkey.substr(0, 8)}}, {profile: ${this._data.mainProfile}}`);
13701
+ console.debug(`[account] Account restoration [OK] {pubkey: ${pubkey.substr(0, 8)}}, {profile: ${this._cache.mainProfile}}`);
13696
13702
  return account;
13697
13703
  });
13698
13704
  }
@@ -13701,13 +13707,13 @@ class AccountService extends BaseGraphqlService {
13701
13707
  */
13702
13708
  saveLocally() {
13703
13709
  return __awaiter(this, void 0, void 0, function* () {
13704
- if (!this._data.pubkey)
13710
+ if (!this._cache.pubkey)
13705
13711
  throw new Error('User not logged');
13706
13712
  if (this._debug)
13707
- console.debug(`[account] Saving account {${this._data.pubkey.substring(0, 6)}} in local storage...`);
13713
+ console.debug(`[account] Saving account {${this._cache.pubkey.substring(0, 6)}} in local storage...`);
13708
13714
  // Convert account to json
13709
- const json = this._data.account.asObject({ keepTypename: true });
13710
- const seckey = this._data.keypair && this._data.keypair.secretKey && Base58.encode(this._data.keypair.secretKey) || null;
13715
+ const json = this._data.asObject({ keepTypename: true });
13716
+ const seckey = this._cache.keypair && this._cache.keypair.secretKey && Base58.encode(this._cache.keypair.secretKey) || null;
13711
13717
  // Convert avatar URL to dataUrl (e.g. 'data:image/png:<base64 content>')
13712
13718
  const hasAvatarUrl = json.avatar && !json.avatar.endsWith(DEFAULT_AVATAR_IMAGE) &&
13713
13719
  (json.avatar.startsWith('http://') || (json.avatar.startsWith('https://')));
@@ -13728,9 +13734,9 @@ class AccountService extends BaseGraphqlService {
13728
13734
  }
13729
13735
  try {
13730
13736
  yield Promise.all([
13731
- this.storage.set(PUBKEY_STORAGE_KEY, this._data.pubkey),
13732
- this.storage.set(TOKEN_STORAGE_KEY, this._data.authToken),
13733
- this.storage.set(`${ACCOUNT_STORAGE_KEY}#${this._data.pubkey}`, json),
13737
+ this.storage.set(PUBKEY_STORAGE_KEY, this._cache.pubkey),
13738
+ this.storage.set(TOKEN_STORAGE_KEY, this._cache.authToken),
13739
+ this.storage.set(`${ACCOUNT_STORAGE_KEY}#${this._cache.pubkey}`, json),
13734
13740
  // Secret key (optional)
13735
13741
  seckey && this.storage.set(SECKEY_STORAGE_KEY, seckey) || this.storage.remove(SECKEY_STORAGE_KEY),
13736
13742
  // Remove old storage key
@@ -13744,6 +13750,22 @@ class AccountService extends BaseGraphqlService {
13744
13750
  }
13745
13751
  });
13746
13752
  }
13753
+ saveLocalSettingsRemotely(source) {
13754
+ return __awaiter(this, void 0, void 0, function* () {
13755
+ if (!source || !this.isLogin())
13756
+ return; // Skip
13757
+ const account = this.account;
13758
+ // Merge local settings into account's settings
13759
+ const settings = UserSettings.fromObject(account.settings) || new UserSettings();
13760
+ const hasChanges = settings.merge(source, ['locale', 'latLongFormat', 'properties']);
13761
+ if (hasChanges) {
13762
+ if (this._debug)
13763
+ console.debug('[account] Save local settings remotely', settings);
13764
+ account.settings = settings;
13765
+ yield this.saveRemotely(account);
13766
+ }
13767
+ });
13768
+ }
13747
13769
  /**
13748
13770
  * Create or update an user account
13749
13771
  *
@@ -13788,7 +13810,7 @@ class AccountService extends BaseGraphqlService {
13788
13810
  }
13789
13811
  authenticateAndGetToken(token, counter) {
13790
13812
  return __awaiter(this, void 0, void 0, function* () {
13791
- if (!this._data.pubkey)
13813
+ if (!this._cache.pubkey)
13792
13814
  throw new Error('User not logged');
13793
13815
  if (!counter)
13794
13816
  console.info('[account] Authentication on pod...');
@@ -13814,7 +13836,7 @@ class AccountService extends BaseGraphqlService {
13814
13836
  if (data && data.authenticate) {
13815
13837
  // Store the token
13816
13838
  this.onAuthTokenChange.next(token);
13817
- console.info(`[account] Authentication on pod [OK] {pubkey: '${this._data.pubkey.substr(0, 8)}'}`);
13839
+ console.info(`[account] Authentication on pod [OK] {pubkey: '${this._cache.pubkey.substr(0, 8)}'}`);
13818
13840
  return token; // return the token
13819
13841
  }
13820
13842
  // Continue (will retry with another challenge)
@@ -13840,8 +13862,8 @@ class AccountService extends BaseGraphqlService {
13840
13862
  }
13841
13863
  // TODO: check server pubkey as a valid certificate
13842
13864
  // Do the challenge
13843
- const signature = yield this.cryptoService.sign(data.authChallenge.challenge, this._data.keypair);
13844
- const newToken = `${this._data.pubkey}:${data.authChallenge.challenge}|${signature}`;
13865
+ const signature = yield this.cryptoService.sign(data.authChallenge.challenge, this._cache.keypair);
13866
+ const newToken = `${this._cache.pubkey}:${data.authChallenge.challenge}|${signature}`;
13845
13867
  // iterate with the new token
13846
13868
  return yield this.authenticateAndGetToken(newToken, (counter || 1) + 1 /* increment */);
13847
13869
  });
@@ -14181,73 +14203,28 @@ class ConfigService extends BaseGraphqlService {
14181
14203
  this.toastController = toastController;
14182
14204
  this.translate = translate;
14183
14205
  this.environment = environment;
14184
- this._started = false;
14185
- this._subscription = new Subscription();
14186
14206
  this.$data = new BehaviorSubject(null);
14187
14207
  this._debug = !environment.production;
14188
14208
  if (this._debug)
14189
14209
  console.debug('[config] Creating service');
14190
14210
  this._optionDefs = Object.values(Object.assign(Object.assign({}, CORE_CONFIG_OPTIONS), defaultOptionsMap));
14191
- // Restart if graphql service restart
14192
- this.graphql.onStart.subscribe(() => this.restart());
14193
- // Start
14194
- if (this.graphql.started) {
14195
- this.start();
14196
- }
14197
- }
14198
- get started() {
14199
- return this._started;
14200
14211
  }
14201
14212
  get config() {
14202
14213
  // If first call: start loading
14203
- if (!this._started)
14214
+ if (!this.started)
14204
14215
  this.start();
14205
14216
  return this.$data.pipe(filter(isNotNil));
14206
14217
  }
14207
- start() {
14208
- if (this._startPromise)
14209
- return this._startPromise;
14210
- if (this._started)
14211
- return;
14212
- console.info('[config] Starting configuration...');
14213
- this._startPromise = this.graphql.ready()
14214
- .then(() => this.loadOrRestoreLocally())
14215
- .then((data) => {
14216
- this._started = true;
14217
- this._startPromise = undefined;
14218
+ ngOnStart() {
14219
+ return __awaiter(this, void 0, void 0, function* () {
14220
+ console.info('[config] Starting configuration...');
14221
+ const data = yield this.loadOrRestoreLocally();
14218
14222
  this.$data.next(data);
14223
+ // Restart if graphql service restart
14224
+ this.registerSubscription(this.graphql.onStart.subscribe(() => this.restart()));
14219
14225
  return data;
14220
- })
14221
- .catch((err) => {
14222
- console.error(err && err.message || err, err);
14223
- this._started = false;
14224
- this._startPromise = undefined;
14225
- return null;
14226
- });
14227
- return this._startPromise;
14228
- }
14229
- stop() {
14230
- return __awaiter(this, void 0, void 0, function* () {
14231
- this._subscription.unsubscribe();
14232
- this._subscription = new Subscription();
14233
- this._started = false;
14234
- this._startPromise = undefined;
14235
- });
14236
- }
14237
- restart() {
14238
- return __awaiter(this, void 0, void 0, function* () {
14239
- if (this.started)
14240
- yield this.stop();
14241
- return this.start();
14242
14226
  });
14243
14227
  }
14244
- ready() {
14245
- if (this._started)
14246
- return Promise.resolve(this.$data.value);
14247
- if (this._startPromise)
14248
- return this._startPromise;
14249
- return this.start();
14250
- }
14251
14228
  loadDefault(opts) {
14252
14229
  return __awaiter(this, void 0, void 0, function* () {
14253
14230
  const now = Date.now();
@@ -19755,12 +19732,6 @@ class BaseEntityService extends BaseGraphqlService {
19755
19732
  this.defaultSortBy = options.defaultSortBy || 'id';
19756
19733
  this.defaultSortDirection = options.defaultSortDirection || 'asc';
19757
19734
  this.watchQueriesUpdatePolicy = options.watchQueriesUpdatePolicy || 'update-cache';
19758
- platform.ready().then(() => {
19759
- // No limit for updatable watch queries, if desktop
19760
- if (!platform.mobile) {
19761
- this._mutableWatchQueriesMaxCount = -1;
19762
- }
19763
- });
19764
19735
  const obj = new dataType();
19765
19736
  this._typename = obj.__typename || 'UnknownVO';
19766
19737
  this._logTypeName = removeEnd(this._typename, 'VO');
@@ -20138,6 +20109,14 @@ class BaseEntityService extends BaseGraphqlService {
20138
20109
  return EntityFilterUtils.fromObject(source, this.filterType);
20139
20110
  }
20140
20111
  /* -- protected functions -- */
20112
+ ngOnStart() {
20113
+ return __awaiter(this, void 0, void 0, function* () {
20114
+ // No limit for updatable watch queries, if desktop
20115
+ if (!this.platform.mobile) {
20116
+ this._mutableWatchQueriesMaxCount = -1;
20117
+ }
20118
+ });
20119
+ }
20141
20120
  fillDefaultProperties(source) {
20142
20121
  // Can be override by subclasses
20143
20122
  }