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,17 +112,22 @@ egw.extend("data", egw.MODULE_APP_LOCAL, function (_app, _wnd)
// Actual cached data // Actual cached data
else if (key.indexOf(_prefix) == 0) else if (key.indexOf(_prefix) == 0)
{ {
var cached = JSON.parse(window.localStorage.getItem(key)); try {
if(cached.timestamp) let cached = JSON.parse(window.localStorage.getItem(key));
{ if(cached.timestamp)
indexes.push({ {
key: key, indexes.push({
lastModification: cached.timestamp key: key,
}); lastModification: cached.timestamp
});
}
else
{
// No way to know how old it is, just remove it
window.localStorage.removeItem(key);
}
} }
else catch (e) {
{
// No way to know how old it is, just remove it
window.localStorage.removeItem(key); window.localStorage.removeItem(key);
} }
} }