refactor guid gen

This commit is contained in:
quenousimporte 2024-02-02 10:41:02 +01:00
parent 090c04eedd
commit 47f0907e77
1 changed files with 7 additions and 2 deletions

View File

@ -312,6 +312,11 @@ var snippets = [
insert: "x " + (new Date).toISOString().substring(0, 10) + " " insert: "x " + (new Date).toISOString().substring(0, 10) + " "
}]; }];
function genguid()
{
return crypto.randomUUID();
}
function purgetodo() { function purgetodo() {
if (currentistodo() && confirm("Remove completed tasks?")) if (currentistodo() && confirm("Remove completed tasks?"))
{ {
@ -1180,7 +1185,7 @@ function loadstorage()
{ {
notesindex = {}; notesindex = {};
// todo: refactor in "add new note" // todo: refactor in "add new note"
var guid = crypto.randomUUID(); var guid = genguid();
var content = defaultheaders(); var content = defaultheaders();
var item = { var item = {
title: timestamp(), title: timestamp(),
@ -1306,7 +1311,7 @@ function migratelegacystorage()
var index = {}; var index = {};
legacy.forEach(note => legacy.forEach(note =>
{ {
var guid = crypto.randomUUID(); var guid = genguid();
localStorage.setItem(guid, note.content); localStorage.setItem(guid, note.content);
note.tags = gettags(note.content); note.tags = gettags(note.content);
delete note.content; delete note.content;