From 8d0b4bef5eef76949fbe3a62bb2f89cc9630a9c1 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Thu, 15 Feb 2024 09:35:09 +0100 Subject: [PATCH] fix legacy migration: use index instead of timestamp to avoid duplicates add a warning message --- main.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index 72fd0cf..bb1266a 100644 --- a/main.js +++ b/main.js @@ -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; });