@veloceapps/sdk 10.0.0-1 → 10.0.0-3

Sign up to get free protection for your applications and to get access to all the features.
@@ -478,7 +478,8 @@ class FlowStateService {
478
478
  this.EXECUTION_BUFFER_TIME = 100;
479
479
  this.executedFunctions = {};
480
480
  this.stateId$ = new BehaviorSubject(null);
481
- this._hasStatefulUnsavedChanges = true;
481
+ this.initialStatefulData = {};
482
+ this.trackedStatefulChangesMap = new Map();
482
483
  this.processors = {};
483
484
  this.subscriptions = {};
484
485
  this.flowStore = {};
@@ -561,7 +562,7 @@ class FlowStateService {
561
562
  }
562
563
  get hasUnsavedChanges() {
563
564
  return this.getFlowSafe().properties.stateful
564
- ? this._hasStatefulUnsavedChanges
565
+ ? Array.from(this.trackedStatefulChangesMap.values()).some(Boolean)
565
566
  : this.quoteDraftService.hasUnsavedChanges;
566
567
  }
567
568
  get stateId() {
@@ -625,6 +626,9 @@ class FlowStateService {
625
626
  data$: new BehaviorSubject(this.NOT_INITIALIZED),
626
627
  };
627
628
  this.subscriptions[requestId] = subscription;
629
+ if (options?.trackedChanges) {
630
+ this.trackedStatefulChangesMap.set(requestId, false);
631
+ }
628
632
  if (!options?.cold) {
629
633
  this.executeRequest$(request).subscribe();
630
634
  }
@@ -715,6 +719,7 @@ class FlowStateService {
715
719
  }
716
720
  const subscription$ = this.subscriptions[requestId]?.data$;
717
721
  if (subscription$ && subscription$.value !== selectorResult) {
722
+ this.checkStatefulChanges(requestId, selectorResult);
718
723
  subscription$.next(selectorResult);
719
724
  }
720
725
  });
@@ -954,6 +959,15 @@ class FlowStateService {
954
959
  });
955
960
  return request;
956
961
  }
962
+ checkStatefulChanges(requestId, selectorResult) {
963
+ if (this.trackedStatefulChangesMap.has(requestId)) {
964
+ if (!this.initialStatefulData[requestId]) {
965
+ this.initialStatefulData[requestId] = selectorResult;
966
+ }
967
+ const hasChanges = !isEqual(this.initialStatefulData[requestId], selectorResult);
968
+ this.trackedStatefulChangesMap.set(requestId, hasChanges);
969
+ }
970
+ }
957
971
  }
958
972
  FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: ContextService }, { token: QuoteDraftService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }, { token: i6.ToastService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
959
973
  FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });