hart-estate-widget 0.0.37 → 0.0.38

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.
@@ -11,10 +11,10 @@ require("core-js/modules/es.regexp.exec.js");
11
11
 
12
12
  require("core-js/modules/es.string.replace.js");
13
13
 
14
- require("core-js/modules/web.dom-collections.iterator.js");
15
-
16
14
  require("core-js/modules/es.string.includes.js");
17
15
 
16
+ require("core-js/modules/web.dom-collections.iterator.js");
17
+
18
18
  var _react = _interopRequireWildcard(require("react"));
19
19
 
20
20
  var _store = _interopRequireDefault(require("../store"));
@@ -47,15 +47,18 @@ const {
47
47
  } = PANOLENS.CONTROLS;
48
48
  const imgExtentions = ['.png', '.PNG', '.jpg', '.JPG'];
49
49
  const pathName = 'Panorama_0_0_';
50
+ const cameraIdBeginning = 'CameraId';
51
+
52
+ const removeExtention = str => imgExtentions.reduce((acc, extention) => {
53
+ return acc.replace(extention, '');
54
+ }, str);
50
55
 
51
56
  const getCameraFromSrc = (json, src) => {
52
57
  var _json$Floors$0$Camera;
53
58
 
54
- const cameraIdIndex = src.indexOf('CameraId');
59
+ const cameraIdIndex = src.indexOf(cameraIdBeginning);
55
60
  if (cameraIdIndex === -1) return null;
56
- const cameraId = imgExtentions.reduce((acc, extention) => {
57
- return acc.replace(extention, '');
58
- }, src.substring(cameraIdIndex));
61
+ const cameraId = removeExtention(src.substring(cameraIdIndex));
59
62
  return ((_json$Floors$0$Camera = json.Floors[0].CameraPoints) === null || _json$Floors$0$Camera === void 0 ? void 0 : _json$Floors$0$Camera.find(_ref => {
60
63
  let {
61
64
  ID
@@ -82,11 +85,15 @@ const getPanoramas = (json, images, setLoadingState) => {
82
85
  if (!json) return images.map((image, index) => createPanorama(image, index, setLoadingState));
83
86
  return json.Floors[0].Units[0].Rooms.reduce((acc, jsonRoom, index) => {
84
87
  const roomImages = images.filter(img => {
85
- const panoramaIdIndex = img.indexOf(pathName);
86
- if (panoramaIdIndex === -1) return false;
87
- const panoramaId = imgExtentions.reduce((acc, extention) => {
88
- return acc.replace(extention, '');
89
- }, img.substring(panoramaIdIndex + pathName.length));
88
+ const panoramaIdIndex = img.indexOf(pathName) + pathName.length;
89
+ if (panoramaIdIndex < pathName.length) return false;
90
+ let panoramaId = removeExtention(img.substring(panoramaIdIndex));
91
+
92
+ if (panoramaId.includes(cameraIdBeginning)) {
93
+ const cameraIdIndex = panoramaId.indexOf(cameraIdBeginning) - 1;
94
+ panoramaId = panoramaId.slice(0, cameraIdIndex);
95
+ }
96
+
90
97
  return Number(panoramaId) === index;
91
98
  });
92
99
  if (!roomImages.length) return acc;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "HART Estate widget",
4
4
  "author": "HART",
5
5
  "keywords": [],
6
- "version": "0.0.37",
6
+ "version": "0.0.38",
7
7
  "private": false,
8
8
  "main": "build/index.js",
9
9
  "module": "build/index.js",