@veloceapps/sdk 10.0.0-2 → 10.0.0-4
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.
- package/core/services/flow-state.service.d.ts +3 -1
- package/core/types/flow-state.types.d.ts +1 -0
- package/esm2020/core/services/flow-state.service.mjs +23 -5
- package/esm2020/core/types/flow-state.types.mjs +1 -1
- package/fesm2015/veloceapps-sdk-core.mjs +21 -3
- package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
- package/fesm2020/veloceapps-sdk-core.mjs +21 -3
- package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
- package/package.json +1 -1
@@ -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.
|
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.
|
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
|
}
|
@@ -638,7 +642,11 @@ class FlowStateService {
|
|
638
642
|
save$() {
|
639
643
|
if (this.getFlowSafe().properties.stateful) {
|
640
644
|
if (this.stateId$.value) {
|
641
|
-
return this.flowStateApiService.save(this.stateId$.value)
|
645
|
+
return this.flowStateApiService.save(this.stateId$.value).pipe(tap$1(() => {
|
646
|
+
Array.from(this.trackedStatefulChangesMap.keys()).forEach(key => {
|
647
|
+
this.trackedStatefulChangesMap.set(key, false);
|
648
|
+
});
|
649
|
+
}));
|
642
650
|
}
|
643
651
|
}
|
644
652
|
else {
|
@@ -715,6 +723,7 @@ class FlowStateService {
|
|
715
723
|
}
|
716
724
|
const subscription$ = this.subscriptions[requestId]?.data$;
|
717
725
|
if (subscription$ && subscription$.value !== selectorResult) {
|
726
|
+
this.checkStatefulChanges(requestId, selectorResult);
|
718
727
|
subscription$.next(selectorResult);
|
719
728
|
}
|
720
729
|
});
|
@@ -954,6 +963,15 @@ class FlowStateService {
|
|
954
963
|
});
|
955
964
|
return request;
|
956
965
|
}
|
966
|
+
checkStatefulChanges(requestId, selectorResult) {
|
967
|
+
if (this.trackedStatefulChangesMap.has(requestId)) {
|
968
|
+
if (!this.initialStatefulData[requestId]) {
|
969
|
+
this.initialStatefulData[requestId] = selectorResult;
|
970
|
+
}
|
971
|
+
const hasChanges = !isEqual(this.initialStatefulData[requestId], selectorResult);
|
972
|
+
this.trackedStatefulChangesMap.set(requestId, hasChanges);
|
973
|
+
}
|
974
|
+
}
|
957
975
|
}
|
958
976
|
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
977
|
FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });
|