fix legacy migration:
use index instead of timestamp to avoid duplicates add a warning message
This commit is contained in:
parent
095bc6dd42
commit
8d0b4bef5e
7
main.js
7
main.js
|
@ -1264,14 +1264,15 @@ function migratelegacystorage()
|
||||||
var legacy = localStorage.getItem("data");
|
var legacy = localStorage.getItem("data");
|
||||||
if (legacy)
|
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 = {};
|
var index = {};
|
||||||
legacy.reverse().forEach(note =>
|
legacy.reverse().forEach( (note, i) =>
|
||||||
{
|
{
|
||||||
var guid = genguid();
|
var guid = genguid();
|
||||||
localStorage.setItem(guid, note.content);
|
localStorage.setItem(guid, note.content);
|
||||||
note.header = indexheader(note.content);
|
note.header = indexheader(note.content);
|
||||||
note.lastchanged = Date.now();
|
note.lastchanged = i;
|
||||||
delete note.content;
|
delete note.content;
|
||||||
index[guid] = note;
|
index[guid] = note;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue