oa-componentbook 1.0.1-stage.43 → 1.0.1-stage.45
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.
|
@@ -13,7 +13,6 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
13
13
|
var _antd = require("antd");
|
|
14
14
|
var _icons = require("@ant-design/icons");
|
|
15
15
|
var _reactZoomPanPinch = require("react-zoom-pan-pinch");
|
|
16
|
-
var _FullscreenExitOutlined = _interopRequireDefault(require("@material-ui/icons/FullscreenExitOutlined"));
|
|
17
16
|
var _Fullscreen = _interopRequireDefault(require("@material-ui/icons/Fullscreen"));
|
|
18
17
|
var _CustomButton = _interopRequireDefault(require("../../components/oa-component-button/CustomButton"));
|
|
19
18
|
var _CustomModal = _interopRequireDefault(require("../../components/oa-component-modal/CustomModal"));
|
|
@@ -124,15 +123,32 @@ function ImageCarouselWidget(_ref) {
|
|
|
124
123
|
setCurrentIndex(newIndex);
|
|
125
124
|
};
|
|
126
125
|
const handleShowHeatmap = async () => {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
126
|
+
const currentViewType = !showHeatmap; // Toggle the current view mode (show heatmap or not)
|
|
127
|
+
setLoading(true);
|
|
128
|
+
|
|
129
|
+
// Fetching URLs for all images based on the new view mode
|
|
130
|
+
const updatedImages = await Promise.all(imageUrls.map(async img => {
|
|
131
|
+
var _img$heatmapImageUrl, _img$originalImageUrl;
|
|
132
|
+
// Check if the image is already fetched
|
|
133
|
+
const isImageAlreadyFetched = currentViewType && ((_img$heatmapImageUrl = img.heatmapImageUrl) === null || _img$heatmapImageUrl === void 0 ? void 0 : _img$heatmapImageUrl.length) > 0 || !currentViewType && ((_img$originalImageUrl = img.originalImageUrl) === null || _img$originalImageUrl === void 0 ? void 0 : _img$originalImageUrl.length) > 0;
|
|
134
|
+
// Fetch the image URL only if it's not already fetched
|
|
135
|
+
if (!isImageAlreadyFetched) {
|
|
136
|
+
const imageSrcUrl = await fetchImageUrl(currentViewType ? img.heatmapDocId : img.originalDocId);
|
|
137
|
+
// Return the updated image object with the appropriate URL
|
|
138
|
+
return _objectSpread(_objectSpread({}, img), currentViewType ? {
|
|
139
|
+
heatmapImageUrl: imageSrcUrl
|
|
140
|
+
} : {
|
|
141
|
+
originalImageUrl: imageSrcUrl
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
// If image is already fetched, return it as is
|
|
145
|
+
return img;
|
|
146
|
+
}));
|
|
147
|
+
|
|
148
|
+
// Update state with the new image URLs
|
|
134
149
|
setImageUrls(updatedImages);
|
|
135
|
-
|
|
150
|
+
setLoading(false);
|
|
151
|
+
setShowHeatmap(currentViewType); // Toggle the view mode
|
|
136
152
|
};
|
|
137
153
|
const currentImage = imageUrls[currentIndex];
|
|
138
154
|
return /*#__PURE__*/_react.default.createElement(_styles.ImageCarouselWidgetStyle, null, /*#__PURE__*/_react.default.createElement(_CustomModal.default, {
|