@sumaris-net/ngx-components 2.4.24 → 2.4.25-rc2

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.
@@ -15302,6 +15302,13 @@ class NetworkService extends StartableObservableService {
15302
15302
  if (await this.checkPeerAlive(detectedPeer)) {
15303
15303
  return detectedPeer;
15304
15304
  }
15305
+ // Peer not alive, but should be at the same URL, retrying each 1s
15306
+ if (this.environment.sameUrlPeer) {
15307
+ return await timer(1000, 1000)
15308
+ .pipe(takeUntil(this.stopSubject), tap(() => console.warn(`[network-service] Waiting peer be be alive, at {${detectedPeer.url}} ...`)), mergeMap(() => this.checkPeerAlive(detectedPeer)), filter(alive => !!alive), map(() => detectedPeer), first()).toPromise();
15309
+ // Stop
15310
+ throw new Error('Service have been stopped');
15311
+ }
15305
15312
  }
15306
15313
  return undefined;
15307
15314
  }
@@ -28140,7 +28147,6 @@ class AppEntityEditor extends AppTabEditor {
28140
28147
  }
28141
28148
  ngOnDestroy() {
28142
28149
  super.ngOnDestroy();
28143
- this._listenChangesSubscription = null; // already unsubscribe in the super function
28144
28150
  this.$title.complete();
28145
28151
  this.$title.unsubscribe();
28146
28152
  this.onUpdateView.complete();
@@ -28214,7 +28220,7 @@ class AppEntityEditor extends AppTabEditor {
28214
28220
  this._usageMode = this.computeUsageMode(data);
28215
28221
  await this.onEntityLoaded(data, opts);
28216
28222
  await this.updateView(data, opts);
28217
- this.startListenRemoteChanges();
28223
+ this.startListenChanges();
28218
28224
  }
28219
28225
  catch (err) {
28220
28226
  this.setError(err);
@@ -28228,18 +28234,17 @@ class AppEntityEditor extends AppTabEditor {
28228
28234
  canUserWrite(data, opts) {
28229
28235
  return this.dataService.canUserWrite(data, opts);
28230
28236
  }
28231
- startListenRemoteChanges() {
28237
+ startListenChanges() {
28232
28238
  // Skip if disable, or already listening
28233
28239
  if (this._listenChangesSubscription || !this._enableListenChanges)
28234
28240
  return;
28235
- // Skip if new or local data
28236
- if (this.isNewData || EntityUtils.isLocal(this.data))
28241
+ // Skip if new (nothing to listen)
28242
+ if (this.isNewData)
28237
28243
  return;
28238
28244
  // Listen for changes on server
28239
- this._listenChangesSubscription = this.listenChanges(this.data.id, {
28245
+ const subscription = this.listenChanges(this.data.id, {
28240
28246
  interval: this._listenIntervalInSeconds
28241
- })
28242
- .pipe(filter(isNotNil), mergeMap((data) => this.saving
28247
+ })?.pipe(filter(isNotNil), mergeMap((data) => this.saving
28243
28248
  // If saving, wait end, to avoid to detect self changes
28244
28249
  ? firstFalse(this.savingSubject).pipe(mapTo(data), debounceTime(500))
28245
28250
  : of(data)))
@@ -28260,16 +28265,19 @@ class AppEntityEditor extends AppTabEditor {
28260
28265
  this.showToast({ message: 'ERROR.DATA_UPDATE_DATE_CHANGED', type: 'warning', showCloseButton: true });
28261
28266
  }
28262
28267
  });
28263
- this._listenChangesSubscription.add(() => this._listenChangesSubscription = null);
28264
- this.registerSubscription(this._listenChangesSubscription);
28265
- }
28266
- stopListenRemoteChanges() {
28267
- if (this._listenChangesSubscription) {
28268
- this.unregisterSubscription(this._listenChangesSubscription);
28269
- this._listenChangesSubscription.unsubscribe();
28270
- this._listenChangesSubscription = null;
28268
+ // Register subscription
28269
+ if (subscription) {
28270
+ this._listenChangesSubscription = subscription;
28271
+ this.registerSubscription(this._listenChangesSubscription);
28272
+ subscription.add(() => {
28273
+ this.unregisterSubscription(subscription);
28274
+ this._listenChangesSubscription = null;
28275
+ });
28271
28276
  }
28272
28277
  }
28278
+ stopListenChanges() {
28279
+ this._listenChangesSubscription?.unsubscribe();
28280
+ }
28273
28281
  async updateView(data, opts) {
28274
28282
  const idChanged = isNotNil(data.id)
28275
28283
  && this.previousDataId !== undefined // Ignore if first loading (=undefined)
@@ -28400,7 +28408,7 @@ class AppEntityEditor extends AppTabEditor {
28400
28408
  });
28401
28409
  // Subscribe to remote changes
28402
28410
  if (!this._listenChangesSubscription)
28403
- this.startListenRemoteChanges();
28411
+ this.startListenChanges();
28404
28412
  this.submitted = false;
28405
28413
  return true;
28406
28414
  }
@@ -28488,7 +28496,7 @@ class AppEntityEditor extends AppTabEditor {
28488
28496
  }
28489
28497
  async unload(opts) {
28490
28498
  await super.unload(opts);
28491
- this.stopListenRemoteChanges();
28499
+ this.stopListenChanges();
28492
28500
  this.form.reset();
28493
28501
  this.registerForms();
28494
28502
  this.data = null;