From 0f25c8173bc25e5f8588892102230097229003d6 Mon Sep 17 00:00:00 2001 From: Artemy Egorov Date: Fri, 5 May 2023 18:41:14 +0300 Subject: [PATCH] fix: note ids --- changelog.md | 2 +- src/pages/save-local.jsx | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 2d12d75..b6756e5 100644 --- a/changelog.md +++ b/changelog.md @@ -29,7 +29,7 @@ - [ ] Settings for publish notes, such as: delete after reading, number of reads before deleting, adding your own data (name, picture, status in the settings) to the note. - [x] Maintaining statistics on sent notes, the number of notes received, number of deleted notes (#8) - [ ] Encrypting notes in the database -- [x] Local notes id is incremental instead of uuidv4 (238af9ad6957f72439a1a39f32662145dd2bdce8) +- [x] Local notes ids is ~~incremental~~ `Date.now()` instead of uuidv4 (238af9ad6957f72439a1a39f32662145dd2bdce8) # AnoPaper v1.0.0 diff --git a/src/pages/save-local.jsx b/src/pages/save-local.jsx index a1d7f2c..ad7bfd5 100644 --- a/src/pages/save-local.jsx +++ b/src/pages/save-local.jsx @@ -26,12 +26,11 @@ function Save() { if (!name || !text) return ; let notesObj = localStorage.getObj("Notes"); - let id = Object.keys(notesObj).length; let time = Date.now(); - notesObj[id] = { - id, + notesObj[time] = { + id: time, name, text, time,