fix legacy migration:

use index instead of timestamp to avoid duplicates
add a warning message
This commit is contained in:
quenousimporte 2024-02-15 09:35:09 +01:00
parent 095bc6dd42
commit 8d0b4bef5e
1 changed files with 4 additions and 3 deletions

View File

@ -1264,14 +1264,15 @@ function migratelegacystorage()
var legacy = localStorage.getItem("data");
if (legacy)
{
var legacy = JSON.parse(legacy);
alert("Old data model detected. Click ok to migrate, or close app.")
legacy = JSON.parse(legacy);
var index = {};
legacy.reverse().forEach(note =>
legacy.reverse().forEach( (note, i) =>
{
var guid = genguid();
localStorage.setItem(guid, note.content);
note.header = indexheader(note.content);
note.lastchanged = Date.now();
note.lastchanged = i;
delete note.content;
index[guid] = note;
});