Hedgehog-Computing/hedgehog-lab

refactor saving local code to IndexedDB

himself65 opened this issue · 2 comments

const getLocalCodeList = () => {
try {
const result = localStorage.getItem('localNameList');
if (result) {
const list = JSON.parse(result) as string[];
const newLocalList = [];
for (let i = 0; i < list.length; i++) {
if (list[i] !== 'localNameList') {
newLocalList.push({
description: list[i],
source: localStorage.getItem(list[i]) as string
});
}
}
//console.log(newLocalList);
setLocalList(newLocalList);
} else {
localStorage.setItem('localNameList', JSON.stringify(['localNameList']));
}
} catch (err) {
throw new Error("Error while getting local code list: " + err);
}
};

Local code has been removed in the latest version, so switch to the Dev branch.

https://github.com/Hedgehog-Computing/hedgehog-lab/blob/dev/packages/hedgehog-lab/src/pages/Main/Main.tsx