hart-estate-widget 0.0.38 → 0.0.39

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/es.string.includes.js");
15
-
16
14
  require("core-js/modules/web.dom-collections.iterator.js");
17
15
 
16
+ require("core-js/modules/es.string.includes.js");
17
+
18
18
  var _react = _interopRequireWildcard(require("react"));
19
19
 
20
20
  var _store = _interopRequireDefault(require("../store"));
@@ -87,14 +87,13 @@ const getPanoramas = (json, images, setLoadingState) => {
87
87
  const roomImages = images.filter(img => {
88
88
  const panoramaIdIndex = img.indexOf(pathName) + pathName.length;
89
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
-
97
- return Number(panoramaId) === index;
90
+ const indexAsString = String(index);
91
+ const panoramaId = String(removeExtention(img.substring(panoramaIdIndex)));
92
+ const maxIndexLength = Math.max(indexAsString.length, panoramaId.length);
93
+ const imageInRoom = (0, _panoramaHelpers.getArrayFromNumber)(maxIndexLength).every(i => {
94
+ return panoramaId[i] === indexAsString[i];
95
+ });
96
+ return imageInRoom;
98
97
  });
99
98
  if (!roomImages.length) return acc;
100
99
  roomImages.forEach(image => {
@@ -59,9 +59,10 @@ class Store {
59
59
  json,
60
60
  panoramaImages
61
61
  } = this.config;
62
+ if (!json) return panoramaImages[0] || null;
62
63
  const roomIndex = json.Floors[0].Units[0].Rooms.findIndex(room => room.ID === this.hallRoomId);
63
64
  const image = panoramaImages.find(url => url.includes("".concat(roomIndex, ".png")));
64
- return image || panoramaImages[0];
65
+ return image || panoramaImages[0] || null;
65
66
  }
66
67
 
67
68
  setConfig(config) {
@@ -3,7 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getScale = exports.getRoomCoordinates = exports.findWallVertices = void 0;
6
+ exports.getScale = exports.getRoomCoordinates = exports.getArrayFromNumber = exports.findWallVertices = void 0;
7
+
8
+ require("core-js/modules/web.dom-collections.iterator.js");
7
9
 
8
10
  require("core-js/modules/es.array.reduce.js");
9
11
 
@@ -11,6 +13,10 @@ var _react = _interopRequireDefault(require("react"));
11
13
 
12
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
15
 
16
+ const getArrayFromNumber = num => [...Array(num).keys()];
17
+
18
+ exports.getArrayFromNumber = getArrayFromNumber;
19
+
14
20
  const findWallVertices = (walls, wall, vertices) => {
15
21
  const currentWall = walls.find(el => el.ID === wall);
16
22
  return currentWall.Vertices.map(vertexId => {
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.38",
6
+ "version": "0.0.39",
7
7
  "private": false,
8
8
  "main": "build/index.js",
9
9
  "module": "build/index.js",