Skip to content

Commit

Permalink
Merge pull request #158 from ahasnawi/blank-widget-issue
Browse files Browse the repository at this point in the history
solve blank widget screen
  • Loading branch information
nteske authored Oct 14, 2021
2 parents 3fdc5b9 + ec6d0c3 commit f7cac29
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 28 deletions.
1 change: 1 addition & 0 deletions src/control/content/components/LocationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class LocationForm extends React.Component {
categories: [],
carousel: [],
deeplinkUrl: "",
querystringUrl: "",
};
let state = Object.assign(model, cloneDeep(this.props.location) || {});
this.setState(state);
Expand Down
53 changes: 30 additions & 23 deletions src/widget/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ window.app = {
return;
}
console.log("RESULT", result);
if (!result) {
return;
}
places.push(
...result
.map((place) => {
Expand Down Expand Up @@ -185,31 +188,33 @@ window.app = {
);
},
calculateDistance(address) {
if(window.app.state.location) {
let origin = {
latitude: window.app.state.location.lat,
longitude: window.app.state.location.lng,
};

let destination = {
latitude: address.lat,
longitude: address.lng
};
let distance = buildfire.geo.calculateDistance(origin, destination, {
decimalPlaces: 5,
});
let str = null;
if (distance < 0.5) {
str = Math.round(distance * 5280).toLocaleString() + " ft";
}
else {
if (window.app.state.distanceUnit) {
str = Math.round(distance * 1.60934).toLocaleString() + " km";
} else {
str = Math.round(distance).toLocaleString() + " mi";
if (address) {
if(window.app.state.location) {
let origin = {
latitude: window.app.state.location.lat,
longitude: window.app.state.location.lng,
};

let destination = {
latitude: address.lat,
longitude: address.lng
};
let distance = buildfire.geo.calculateDistance(origin, destination, {
decimalPlaces: 5,
});
let str = null;
if (distance < 0.5) {
str = Math.round(distance * 5280).toLocaleString() + " ft";
}
else {
if (window.app.state.distanceUnit) {
str = Math.round(distance * 1.60934).toLocaleString() + " km";
} else {
str = Math.round(distance).toLocaleString() + " mi";
}
}
return str;
}
return str;
}
},
init: (placesCallback, positionCallback) => {
Expand Down Expand Up @@ -265,6 +270,8 @@ window.app = {
localStorage.setItem('user_location', JSON.stringify(window.app.state.location))
buildfire.spinner.hide();
getPlacesList()
} else {
buildfire.spinner.hide();
}
});
}
Expand Down
14 changes: 9 additions & 5 deletions src/widget/js/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,12 @@ window.listView = {
if (!place.address || !place.address.lat || !place.address.lng) {
return;
}

document.getElementsByClassName(
"list-scrolling-container"
)[0].style.height = `${window.listView.imageHeight + 20}px;`;
//to handle style of undefined
let listScrollingContainer = document.getElementsByClassName("list-scrolling-container")[0];
if(!listScrollingContainer) {
return;
}
listScrollingContainer.style.height = `${window.listView.imageHeight + 20}px;`;

const listItem = document.createElement("div");
listItem.setAttribute(
Expand Down Expand Up @@ -192,7 +194,9 @@ window.listView = {
window.listView.listScrollingContainer.appendChild(listItem);
}
});
window.listView.listScrollingContainer.appendChild(emptyItem);
if (window.listView.listScrollingContainer) {
window.listView.listScrollingContainer.appendChild(emptyItem);
}
},
initList: (places) => {
//Add filter control
Expand Down
2 changes: 2 additions & 0 deletions src/widget/js/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ window.mapView = {
myImg.style.filter = "";
buildfire.spinner.hide();
} else buildfire.spinner.hide();
} else {
buildfire.spinner.hide();
}
}

Expand Down

0 comments on commit f7cac29

Please sign in to comment.