mirror of
https://github.com/artegoser/AnoPaper.git
synced 2024-11-21 19:36:22 +03:00
fix: notes ids now incremental
This commit is contained in:
parent
c93062229d
commit
238af9ad69
1 changed files with 1 additions and 10 deletions
|
@ -18,17 +18,7 @@
|
||||||
import { Navigate } from "react-router-dom";
|
import { Navigate } from "react-router-dom";
|
||||||
import { timestamp2text } from "../components/utils";
|
import { timestamp2text } from "../components/utils";
|
||||||
|
|
||||||
function uuidv4() {
|
|
||||||
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>
|
|
||||||
(
|
|
||||||
c ^
|
|
||||||
(crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))
|
|
||||||
).toString(16)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function Save() {
|
function Save() {
|
||||||
let id = uuidv4();
|
|
||||||
let name = localStorage.getItem("NoteName");
|
let name = localStorage.getItem("NoteName");
|
||||||
let text = localStorage.getItem("NoteText");
|
let text = localStorage.getItem("NoteText");
|
||||||
let pubTime = Number(localStorage.getItem("NotePubTime"));
|
let pubTime = Number(localStorage.getItem("NotePubTime"));
|
||||||
|
@ -36,6 +26,7 @@ function Save() {
|
||||||
if (!name || !text) return <Navigate to={`/notes`} replace={true} />;
|
if (!name || !text) return <Navigate to={`/notes`} replace={true} />;
|
||||||
|
|
||||||
let notesObj = localStorage.getObj("Notes");
|
let notesObj = localStorage.getObj("Notes");
|
||||||
|
let id = Object.keys(notesObj).length;
|
||||||
|
|
||||||
let time = Date.now();
|
let time = Date.now();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue