From 998e6e76fa53f4459e4e9c19dfd9409b80720426 Mon Sep 17 00:00:00 2001 From: Rob Court Date: Wed, 3 Jul 2024 16:02:32 +0100 Subject: [PATCH 1/2] handling fails gracefully --- components/interface/VFBTree/VFBTree.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/interface/VFBTree/VFBTree.js b/components/interface/VFBTree/VFBTree.js index 5f72cb508..adb18ee57 100644 --- a/components/interface/VFBTree/VFBTree.js +++ b/components/interface/VFBTree/VFBTree.js @@ -291,7 +291,11 @@ class VFBTree extends React.Component { })) })) }; - localStorage.setItem(cacheKey, JSON.stringify(filteredData)); + try { + localStorage.setItem(cacheKey, JSON.stringify(filteredData)); + } catch (e) { + console.error('Error saving to localStorage:', e); + } const dataTree = this.parseGraphResultData(data); const vertix = this.findRoot(data); const imagesMap = this.buildDictClassToIndividual(data); From b3d218828936fc286cf5110e11c2a57806911f49 Mon Sep 17 00:00:00 2001 From: Rob Court Date: Wed, 3 Jul 2024 16:10:03 +0100 Subject: [PATCH 2/2] clearing localstore if full --- components/interface/VFBTree/VFBTree.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/components/interface/VFBTree/VFBTree.js b/components/interface/VFBTree/VFBTree.js index adb18ee57..d10c2eb68 100644 --- a/components/interface/VFBTree/VFBTree.js +++ b/components/interface/VFBTree/VFBTree.js @@ -295,6 +295,15 @@ class VFBTree extends React.Component { localStorage.setItem(cacheKey, JSON.stringify(filteredData)); } catch (e) { console.error('Error saving to localStorage:', e); + if (e.name === 'QuotaExceededError') { + console.warn('LocalStorage is full, clearing all data'); + localStorage.clear(); + try { + localStorage.setItem(cacheKey, JSON.stringify(filteredData)); + } catch (e) { + console.error('Error saving to localStorage after clearing:', e); + } + } } const dataTree = this.parseGraphResultData(data); const vertix = this.findRoot(data);