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 favoriteItem function
thecodrrf1b92581bc1d
diff --git a/packages/core/api/database.js b/packages/core/api/database.jsindex 9b0cde839..5a8e9fd35 100644--- a/packages/core/api/database.js+++ b/packages/core/api/database.js@@ -151,20 +151,12 @@ 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");- }+ pinItem(type, id) {+ return editItem.call(this, type, id, { pinned: true });+ }++ favoriteItem(type, id) {+ return editItem.call(this, type, id, { favorite: true });}/**@@ -495,3 +487,19 @@ function makeTopic(topic) {notes: []};}++async function editItem(type, id, edit) {+ 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], ...edit });+ break;+ default:+ throw new Error("Invalid type given to pinItem");+ }+}