fix/catch JSON.parse Syntax error when clearing up localStorage

This commit is contained in:
ralf 2024-07-16 12:39:31 +02:00
parent 6e5a691a74
commit e1dd89c57a

View File

@ -112,7 +112,8 @@ egw.extend("data", egw.MODULE_APP_LOCAL, function (_app, _wnd)
// Actual cached data
else if (key.indexOf(_prefix) == 0)
{
var cached = JSON.parse(window.localStorage.getItem(key));
try {
let cached = JSON.parse(window.localStorage.getItem(key));
if(cached.timestamp)
{
indexes.push({
@ -126,6 +127,10 @@ egw.extend("data", egw.MODULE_APP_LOCAL, function (_app, _wnd)
window.localStorage.removeItem(key);
}
}
catch (e) {
window.localStorage.removeItem(key);
}
}
}
// Nothing for that prefix? Clear all cached data.
if(_prefix && indexes.length == 0)