fix: wrap localStorage sets in try/catch

This commit is contained in:
Sam Potts 2021-09-29 21:43:52 +10:00
parent 9f7725cec1
commit e0b70d53cd
2 changed files with 15 additions and 7 deletions

View File

@ -70,7 +70,11 @@ class Storage {
extend(storage, object);
// Update storage
try {
window.localStorage.setItem(this.key, JSON.stringify(storage));
} catch (_) {
// Do nothing
}
};
}

View File

@ -60,12 +60,16 @@ export default function loadSprite(url, id) {
}
if (useStorage) {
try {
window.localStorage.setItem(
`${prefix}-${id}`,
JSON.stringify({
content: result,
}),
);
} catch (_) {
// Do nothing
}
}
update(container, result);