Files
notesnook/packages/core/utils/id.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

/*
This file is part of the Notesnook project (https://notesnook.com/)
2023-01-16 13:44:52 +05:00
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
2022-08-30 16:13:11 +05:00
import SparkMD5 from "spark-md5";
import ObjectID from "./object-id";
export default function () {
return new ObjectID().toHexString();
}
export function makeId(text) {
return SparkMD5.hash(text);
}
feat: add note version history (#20) * feat: note version history * fix bugs * add tests for session history * update tests * add tests for restoring content * add more tests * update jsdoc * return empty array if no session history present for a note * init note history with await * add note history versions limit * cleanup note history after adding a new session * fix tests * add test for session cleanup * test: add collector tests * feat: dateEdited -> dateModified * feat: migrate to liqe for searching * chore: forceExit jest after test run * feat: note version history * fix bugs * add tests for session history * update tests * add tests for restoring content * add more tests * update jsdoc * return empty array if no session history present for a note * init note history with await * add note history versions limit * cleanup note history after adding a new session * fix tests * add test for session cleanup * init ContentHistory with await * fix reference to db in init * make sessionId in db * check if note is locked through note metadata * make cleanup method private * use remove methods in notehistory and contenthistory * restore note content via notes.add method if note is not locked * move getting all items to seperate functions * check if parsed json is valid * deserialize a session only if it's sessionContent exists * add locked property to sessionContent * remove makeSessionId function * update tests * remove yarn.lock file * update tests Co-authored-by: ammarahm-ed <ammarahmed6506@gmail.com>
2021-12-21 13:41:08 +05:00
/**
*
* @param {string} noteId id of a note
* @returns {string} An id with postfix of "_index"
*/
export function makeSessionContentId(sessionId) {
return sessionId + "_content";
}