ctucx.git: oeffisearch

[nimlang] fast and simple tripplanner

commit 90a4e70fe0d2a65505b150eceb7e0430598fd7cd
parent f994059eae5cbd0a6c8b262fb97b5c84ce52605a
Author: ctucx <c@ctu.cx>
Date: Tue, 11 Feb 2020 15:07:12 +0100

hotfix: clear cached joruneys if localstorage is full
1 file changed, 11 insertions(+), 3 deletions(-)
M
client/js/app_functions.js
|
14
+++++++++++---
diff --git a/client/js/app_functions.js b/client/js/app_functions.js
@@ -145,10 +145,18 @@ export const clearDataStorage = () => {
 };
 
 export const saveDataStorage  = () => {
+	let name = 'dataStorage_dev';
+
 	if (devMode !== true) {
-		localStorage.setItem('dataStorage', JSON.stringify(dataStorage));
-	} else {
-		localStorage.setItem('dataStorage_dev', JSON.stringify(dataStorage));
+		name = 'dataStorage';
+	}
+	
+	try {
+		localStorage.setItem(name, JSON.stringify(dataStorage));
+	} catch (e) {
+		ConsoleLog("yikes, localstorage full, clear it...")
+		dataStorage.journeys = {};
+		saveDataStorage();
 	}
 };