Commit 8941ed9e authored by Mattias J Duffy's avatar Mattias J Duffy
Browse files

localstorage fails gracefully

parent 7f8a0cc9
Pipeline #1771 passed with stage
in 1 minute and 41 seconds
......@@ -21,13 +21,19 @@ class Layout extends React.Component {
than an API call). After retrieving from local storage, then call the API to see if there
are any updates.
*/
if (localStorage.getItem('facilities')) {
const facilities = localStorage.getItem('facilities');
this.props.setFacilities(facilities)
}
if (localStorage.getItem('favorites')) {
const favorites = JSON.parse(localStorage.getItem('favorites'));
this.props.setAllFavorites(favorites);
try {
localStorage = window.localStorage;
if (localStorage.getItem('facilities')) {
const facilities = localStorage.getItem('facilities');
this.props.setFacilities(facilities)
}
if (localStorage.getItem('favorites')) {
const favorites = JSON.parse(localStorage.getItem('favorites'));
this.props.setAllFavorites(favorites);
}
} catch(e) {
console.log('you should enable cookies so we can remember what places you favorite')
}
this.props.getFacilities()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment