From 0bead5f6f38add61413302300e90d3b7700f6ac9 Mon Sep 17 00:00:00 2001 From: Tim Cowlishaw Date: Mon, 20 Nov 2023 14:16:19 +0100 Subject: [PATCH] Don't error if storing markers in localstorage throws an error 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. --- src/app/core/api/device.service.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/core/api/device.service.js b/src/app/core/api/device.service.js index 7ff05c75..78e0c71e 100644 --- a/src/app/core/api/device.service.js +++ b/src/app/core/api/device.service.js @@ -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; }