refactor index serialization

This commit is contained in:
quenousimporte 2024-02-15 11:07:21 +01:00
parent a9cb693318
commit e9ac918775
1 changed files with 9 additions and 4 deletions

13
main.js
View File

@ -1126,7 +1126,7 @@ function createnote(title)
header: indexheader(content)
};
metadata[guid] = item;
localStorage.setItem("index", JSON.stringify(metadata));
serializeindex()
localStorage.setItem(guid, content);
return guid;
}
@ -1811,7 +1811,7 @@ function serialize()
item.header = indexheader(md.value);
item.lastchanged = Date.now();
localStorage.setItem("index", JSON.stringify(metadata));
serializeindex()
localStorage.setItem(guid, md.value);
}
else if (title.value == "settings.json")
@ -2375,18 +2375,23 @@ function restoredeleted()
metadata[guid].deleted = false;
metadata[guid].lastchanged = Date.now();
renameinternallinks(title + " (deleted)", title);
localStorage.setItem("index", JSON.stringify(metadata));
serializeindex();
}
});
}
function serializeindex()
{
localStorage.setItem("index", JSON.stringify(metadata));
}
function deletenote(title)
{
var guid = getguid(title);
metadata[guid].deleted = true;
metadata[guid].lastchanged = Date.now();
renameinternallinks(title, title + " (deleted)");
localStorage.setItem("index", JSON.stringify(metadata));
serializeindex()
}
function deletecurrentnote()