Skip to content

Commit f7cac29

Browse files
authored
Merge pull request #158 from ahasnawi/blank-widget-issue
solve blank widget screen
2 parents 3fdc5b9 + ec6d0c3 commit f7cac29

4 files changed

Lines changed: 42 additions & 28 deletions

File tree

src/control/content/components/LocationForm.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ class LocationForm extends React.Component {
2525
categories: [],
2626
carousel: [],
2727
deeplinkUrl: "",
28+
querystringUrl: "",
2829
};
2930
let state = Object.assign(model, cloneDeep(this.props.location) || {});
3031
this.setState(state);

src/widget/js/app.js

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ window.app = {
150150
return;
151151
}
152152
console.log("RESULT", result);
153+
if (!result) {
154+
return;
155+
}
153156
places.push(
154157
...result
155158
.map((place) => {
@@ -185,31 +188,33 @@ window.app = {
185188
);
186189
},
187190
calculateDistance(address) {
188-
if(window.app.state.location) {
189-
let origin = {
190-
latitude: window.app.state.location.lat,
191-
longitude: window.app.state.location.lng,
192-
};
193-
194-
let destination = {
195-
latitude: address.lat,
196-
longitude: address.lng
197-
};
198-
let distance = buildfire.geo.calculateDistance(origin, destination, {
199-
decimalPlaces: 5,
200-
});
201-
let str = null;
202-
if (distance < 0.5) {
203-
str = Math.round(distance * 5280).toLocaleString() + " ft";
204-
}
205-
else {
206-
if (window.app.state.distanceUnit) {
207-
str = Math.round(distance * 1.60934).toLocaleString() + " km";
208-
} else {
209-
str = Math.round(distance).toLocaleString() + " mi";
191+
if (address) {
192+
if(window.app.state.location) {
193+
let origin = {
194+
latitude: window.app.state.location.lat,
195+
longitude: window.app.state.location.lng,
196+
};
197+
198+
let destination = {
199+
latitude: address.lat,
200+
longitude: address.lng
201+
};
202+
let distance = buildfire.geo.calculateDistance(origin, destination, {
203+
decimalPlaces: 5,
204+
});
205+
let str = null;
206+
if (distance < 0.5) {
207+
str = Math.round(distance * 5280).toLocaleString() + " ft";
208+
}
209+
else {
210+
if (window.app.state.distanceUnit) {
211+
str = Math.round(distance * 1.60934).toLocaleString() + " km";
212+
} else {
213+
str = Math.round(distance).toLocaleString() + " mi";
214+
}
210215
}
216+
return str;
211217
}
212-
return str;
213218
}
214219
},
215220
init: (placesCallback, positionCallback) => {
@@ -265,6 +270,8 @@ window.app = {
265270
localStorage.setItem('user_location', JSON.stringify(window.app.state.location))
266271
buildfire.spinner.hide();
267272
getPlacesList()
273+
} else {
274+
buildfire.spinner.hide();
268275
}
269276
});
270277
}

src/widget/js/list.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,12 @@ window.listView = {
115115
if (!place.address || !place.address.lat || !place.address.lng) {
116116
return;
117117
}
118-
119-
document.getElementsByClassName(
120-
"list-scrolling-container"
121-
)[0].style.height = `${window.listView.imageHeight + 20}px;`;
118+
//to handle style of undefined
119+
let listScrollingContainer = document.getElementsByClassName("list-scrolling-container")[0];
120+
if(!listScrollingContainer) {
121+
return;
122+
}
123+
listScrollingContainer.style.height = `${window.listView.imageHeight + 20}px;`;
122124

123125
const listItem = document.createElement("div");
124126
listItem.setAttribute(
@@ -192,7 +194,9 @@ window.listView = {
192194
window.listView.listScrollingContainer.appendChild(listItem);
193195
}
194196
});
195-
window.listView.listScrollingContainer.appendChild(emptyItem);
197+
if (window.listView.listScrollingContainer) {
198+
window.listView.listScrollingContainer.appendChild(emptyItem);
199+
}
196200
},
197201
initList: (places) => {
198202
//Add filter control

src/widget/js/map.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ window.mapView = {
6969
myImg.style.filter = "";
7070
buildfire.spinner.hide();
7171
} else buildfire.spinner.hide();
72+
} else {
73+
buildfire.spinner.hide();
7274
}
7375
}
7476

0 commit comments

Comments
 (0)