Confirm migration if imported from http

This commit is contained in:
Robbie Antenesse 2019-06-09 13:04:16 -06:00 committed by Robbie Antenesse
parent acb94637c5
commit a3b9a0a934
1 changed files with 5 additions and 2 deletions

View File

@ -64,11 +64,14 @@ function dictionaryIsOldDefault(dictionaryJSON) {
function checkForReceived() { function checkForReceived() {
if (window.hasOwnProperty('dictionaryImportedFromHTTP')) { if (window.hasOwnProperty('dictionaryImportedFromHTTP')) {
let saveOld = true;
const storedDictionary = window.localStorage.getItem(LOCAL_STORAGE_KEY); const storedDictionary = window.localStorage.getItem(LOCAL_STORAGE_KEY);
if (!storedDictionary) { if (storedDictionary) {
saveOld = confirm('You have an old local dictionary to import. Would you like to overwrite your current local dictionary?');
}
if (saveOld) {
window.localStorage.setItem(LOCAL_STORAGE_KEY, window.dictionaryImportedFromHTTP); window.localStorage.setItem(LOCAL_STORAGE_KEY, window.dictionaryImportedFromHTTP);
delete window.dictionaryImportedFromHTTP; delete window.dictionaryImportedFromHTTP;
return;
} }
} }
} }