{
console.log(importFiles);
let reader = new FileReader();
reader.onload = async (event) => {
let savedModels = JSON.parse(event.target.result);
console.log(savedModels);
for (const model of savedModels) {
if (model?.info ?? false) {
if ($models.find((m) => m.id === model.id)) {
await updateModelById(localStorage.token, model.id, model.info).catch((error) => {
return null;
});
} else {
await addNewModel(localStorage.token, model.info).catch((error) => {
return null;
});
}
}
}
await models.set(await getModels(localStorage.token));
_models = $models;
};
reader.readAsText(importFiles[0]);
}}
/>