Skip to content

Commit

Permalink
Don't error if storing markers in localstorage throws an error
Browse files Browse the repository at this point in the history
The bug on some versions of safari was caused by this - for reasons unknown it was throwing a quota exceeded error when we go to cache the markers.
The app appears to work without this in any case, so we just catch the error and log an informational message before carrying on, which fixes the safari issue.
  • Loading branch information
timcowlishaw committed Nov 20, 2023
1 parent bce8e5f commit 0bead5f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/core/api/device.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@
timestamp: new Date(),
data: data
};

$window.localStorage.setItem('smartcitizen.markers', JSON.stringify(obj) );
try {
$window.localStorage.setItem('smartcitizen.markers', JSON.stringify(obj) );
} catch {
console.log("Could not store markers in localstorage. skipping...");
}
worldMarkers = obj.data;
}

Expand Down

0 comments on commit 0bead5f

Please sign in to comment.