A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
feat: add pinItem function
thecodrrc04b48667e52
diff --git a/packages/core/api/database.js b/packages/core/api/database.jsindex d37925661..9b0cde839 100644--- a/packages/core/api/database.js+++ b/packages/core/api/database.js@@ -12,7 +12,8 @@ import {const KEYS = {notes: "notes",notebooks: "notebooks",- trash: "trash"+ trash: "trash",+ tags: "tags"};function checkInitialized() {@@ -37,7 +38,7 @@ class Database {for (let key of extractValues(KEYS)) {this.storage.read(key).then(data => {this[key] = data || {};- if (key === "notebooks") {+ if (key === KEYS.tags) {this.isInitialized = true;//TODO use index hereresolve(true);@@ -150,6 +151,22 @@ class Database {return timestamp;}+ async pinItem(type, id) {+ switch (type) {+ case "notebook":+ case "note":+ col = type == "note" ? this.notes : this.notebooks;+ func = type == "note" ? this.addNote : this.addNotebook;+ if (col[id] === undefined) {+ throw new Error(`Wrong ${type} id.`);+ }+ await func({ ...col[id], pinned: true });+ break;+ default:+ throw new Error("Invalid type given to pinItem");+ }+ }+/*** Deletes one or more notes* @param {array} notes the notes to be deleted