diff --git a/html/options.html b/html/options.html index 1d0fe25..d4d37fd 100644 --- a/html/options.html +++ b/html/options.html @@ -86,7 +86,7 @@

● Functional changes

Donate money! - +

Oops, there's an error!

diff --git a/js/options.js b/js/options.js index ece9f42..3a3e4b1 100644 --- a/js/options.js +++ b/js/options.js @@ -468,7 +468,9 @@ These editors are generally found in your email client like Gmail, Outlook, etc. // an HTML element reader.addEventListener("load", (event) => { const importFileData = event.target.result; - console.log("Data got", importFileData); + console.log("Data got\n", importFileData); + window.Data = {}; + Data.snippets = new Folder(Folder.MAIN_SNIPPETS_NAME); initiateRestore(importFileData, Data.snippets, true); }); diff --git a/js/snippetClasses.js b/js/snippetClasses.js index 237b37a..731a9bd 100644 --- a/js/snippetClasses.js +++ b/js/snippetClasses.js @@ -269,9 +269,15 @@ Generic.isValidName = function (name, type) { return `Name cannot be greater than ${OBJECT_NAME_LIMIT} characters. Current name has ${name.length - OBJECT_NAME_LIMIT} more characters.`; } - return Data.snippets.getUniqueObject(name, type) - ? Generic.getDuplicateObjectsText(name, type) - : "true"; + + // error may occur during no-db-restore + try { + const dupeExists = Data.snippets.getUniqueObject(name, type); + if (dupeExists) { return Generic.getDuplicateObjectsText(name, type); } + return "true"; + } catch (e) { + return "true"; + } }; /**