medusa-product-helper 0.0.24 → 0.0.25
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.
|
@@ -1017,14 +1017,14 @@ const ProductMetadataTableWidget = ({ data }) => {
|
|
|
1017
1017
|
}, [productId]);
|
|
1018
1018
|
const metadataStringRef = react.useRef("");
|
|
1019
1019
|
react.useEffect(() => {
|
|
1020
|
-
const
|
|
1020
|
+
const hasProductData = !!data;
|
|
1021
1021
|
const descriptorsLoaded = descriptors.length > 0;
|
|
1022
1022
|
const sameProduct = previousProductIdRef.current === productId;
|
|
1023
1023
|
const notInitialized = !isInitializedRef.current;
|
|
1024
|
-
const
|
|
1024
|
+
const currentMetadata = (data == null ? void 0 : data.metadata) ?? {};
|
|
1025
|
+
const currentMetadataString = JSON.stringify(currentMetadata);
|
|
1025
1026
|
const metadataChanged = currentMetadataString !== metadataStringRef.current;
|
|
1026
|
-
if (
|
|
1027
|
-
const currentMetadata = data.metadata ?? {};
|
|
1027
|
+
if (hasProductData && descriptorsLoaded && sameProduct && (notInitialized || metadataChanged)) {
|
|
1028
1028
|
const newInitialState = buildInitialFormState(descriptors, currentMetadata);
|
|
1029
1029
|
setBaselineMetadata(currentMetadata);
|
|
1030
1030
|
setValues(newInitialState);
|
|
@@ -1016,14 +1016,14 @@ const ProductMetadataTableWidget = ({ data }) => {
|
|
|
1016
1016
|
}, [productId]);
|
|
1017
1017
|
const metadataStringRef = useRef("");
|
|
1018
1018
|
useEffect(() => {
|
|
1019
|
-
const
|
|
1019
|
+
const hasProductData = !!data;
|
|
1020
1020
|
const descriptorsLoaded = descriptors.length > 0;
|
|
1021
1021
|
const sameProduct = previousProductIdRef.current === productId;
|
|
1022
1022
|
const notInitialized = !isInitializedRef.current;
|
|
1023
|
-
const
|
|
1023
|
+
const currentMetadata = (data == null ? void 0 : data.metadata) ?? {};
|
|
1024
|
+
const currentMetadataString = JSON.stringify(currentMetadata);
|
|
1024
1025
|
const metadataChanged = currentMetadataString !== metadataStringRef.current;
|
|
1025
|
-
if (
|
|
1026
|
-
const currentMetadata = data.metadata ?? {};
|
|
1026
|
+
if (hasProductData && descriptorsLoaded && sameProduct && (notInitialized || metadataChanged)) {
|
|
1027
1027
|
const newInitialState = buildInitialFormState(descriptors, currentMetadata);
|
|
1028
1028
|
setBaselineMetadata(currentMetadata);
|
|
1029
1029
|
setValues(newInitialState);
|