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
fix: all api related issues
thecodrraf097e4b5091
diff --git a/apps/web/src/components/dialogs/index.js b/apps/web/src/components/dialogs/index.jsindex 2a9f96c53..c225607dc 100644--- a/apps/web/src/components/dialogs/index.js+++ b/apps/web/src/components/dialogs/index.js@@ -309,7 +309,7 @@ export const ask = (icon, title, message) => {};export const MoveDialog = props => {- const [items, setItems] = useState(db.notebooks.all /*db.getNotebooks()*/);+ const [items, setItems] = useState(db.notebooks.all);const [type, setType] = useState("notebooks");const [title, setTitle] = useState("Notebooks");const [mode, setMode] = useState("read");@@ -374,18 +374,13 @@ export const MoveDialog = props => {if (type === "notebooks") {await db.notebooks.add({title: e.target.value- }); /*db.addNotebook({ title: e.target.value });*/- setItems(db.notebooks.all /*db.getNotebooks()*/);+ });+ setItems(db.notebooks.all);} else {await db.notebooks.notebook(MoveDialog.notebook.id).topics.add(e.target.value);- /*db.addTopicToNotebook(- MoveDialog.notebook.dateCreated,- e.target.value- );*/setItems(- /*db.getNotebook(MoveDialog.notebook.dateCreated).topics*/db.notebooks.notebook(MoveDialog.notebook.id).topics);}@@ -430,10 +425,9 @@ export const MoveDialog = props => {MoveDialog.topic = v.title;setTitle(`${MoveDialog.notebook.title} - ${v.title}`);setItems(- /*db.getTopic(MoveDialog.notebook.dateCreated, v.title)*/db.notebooks.notebook(MoveDialog.notebook.id)- .topics.exists(v.title)+ .topics.topic(v.title).all);}}}@@ -462,18 +456,14 @@ export const MoveDialog = props => {positiveButton={{text: "Move",click: async () => {- if (- await db.notes.move(- MoveDialog.topic,- props.noteId- ) /*db.moveNote(props.noteId, props.notebook, {- notebook: MoveDialog.notebook.dateCreated,- topic: MoveDialog.topic- })*/- ) {+ try {+ await db.notes.move(MoveDialog.topic, props.noteId);props.onMove();+ } catch (e) {+ console.log(e);+ } finally {+ props.onClose();}- props.onClose();},disabled: type !== "notes"}}diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.jsindex 4826a40f7..9d213710d 100644--- a/apps/web/src/components/editor/index.js+++ b/apps/web/src/components/editor/index.js@@ -112,7 +112,9 @@ export default class Editor extends React.Component {onOpenNote(note) {if (!note) return;- this.onNewNote(false, () => {+ this.onNewNote(false, async () => {+ let dbNote = db.notes.note(note.id);+ if (!dbNote) return this.onNewNote(false);this.id = note.id;this.title = note.title;this.titleRef.value = note.title;@@ -123,7 +125,8 @@ export default class Editor extends React.Component {favorite: this.favorite,colors: note.colors});- this.quill.setContents(note.content.delta);+ let delta = await dbNote.delta();+ this.quill.setContents(delta);this.quill.setSelection(note.content.text.length - 1, 0); //to move the cursor to the end});}@@ -144,8 +147,7 @@ export default class Editor extends React.Component {colors: this.state.colors//TODO add tags once the database is done};- let t = await db.notes.add(note); //db.addNote(note);- return t;+ return await db.notes.add(note);}save() {diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.jsindex 7dd24d77f..078a01fbb 100644--- a/apps/web/src/components/note/index.js+++ b/apps/web/src/components/note/index.js@@ -23,7 +23,7 @@ const menuItems = note => [onClick: async () =>db.notes.note(note.id)- .pin() /*db.pinItem("note", note.dateCreated)*/+ .pin().then(() => {showSnack("Note pinned!", Icon.Check);ev.emit("refreshNotes");@@ -34,7 +34,7 @@ const menuItems = note => [onClick: async () =>db.notes.note(note.id)- .favorite() /*db.favoriteItem("note", note.dateCreated)*/+ .favorite().then(() => {showSnack("Note favorited!", Icon.Check);ev.emit("refreshNotes");@@ -55,7 +55,7 @@ const menuItems = note => [if (res) {ev.emit("onClearNote", note.id);db.notes- .delete(note.id) /*db.deleteNotes(note)*/+ .delete(note.id).then(//TODO implement undo() => {diff --git a/apps/web/src/components/notebook/index.js b/apps/web/src/components/notebook/index.jsindex 7b141539d..634cf4adc 100644--- a/apps/web/src/components/notebook/index.js+++ b/apps/web/src/components/notebook/index.js@@ -12,7 +12,7 @@ const menuItems = notebook => [onClick: async () =>db.notebooks.notebook(notebook.id)- .pin() /*db.pinItem("notebook", notebook.dateCreated)*/+ .pin().then(() => {showSnack("Notebook pinned!", Icon.Check);ev.emit("refreshNotebooks");@@ -23,7 +23,7 @@ const menuItems = notebook => [onClick: async () =>db.notebooks.notebook(notebook.id)- .favorite() /*db.favoriteItem("notebook", notebook.dateCreated)*/+ .favorite().then(() => {showSnack("Notebook favorited!", Icon.Check);ev.emit("refreshNotebooks");@@ -35,7 +35,7 @@ const menuItems = notebook => [title: "Delete",color: "red",onClick: () => {- db.notebooks.delete(notebook.id) /*db.deleteNotebooks([notebook])*/.then(+ db.notebooks.delete(notebook.id).then(//TODO implement undo() => {showSnack("Notebook deleted!", Icon.Check);diff --git a/apps/web/src/interfaces/storage.js b/apps/web/src/interfaces/storage.jsindex f60afecf4..33fb08f7e 100644--- a/apps/web/src/interfaces/storage.js+++ b/apps/web/src/interfaces/storage.js@@ -1,5 +1,10 @@import localforage from "localforage";+localforage.config({+ name: "Notesnook",+ driver: [localforage.INDEXEDDB, localforage.WEBSQL, localforage.LOCALSTORAGE]+});+async function read(key) {return localforage.getItem(key);}diff --git a/apps/web/src/views/Favorites.js b/apps/web/src/views/Favorites.jsindex 64934668c..e68a2e2a4 100644--- a/apps/web/src/views/Favorites.js+++ b/apps/web/src/views/Favorites.js@@ -15,16 +15,16 @@ const menuItems = item => ["Are you sure you want to remove this item from favorites?").then(res => {if (res) {- item.type === "notes"- ? db.notes.favorites(item.id)- : db.notebooks- .notebook(item.id)- .favorite() /*db.favoriteItem(item.type, item.dateCreated)*/- .then(() => {- let itemType = item.type[0] + item.type.substring(1);- showSnack(itemType + " Unfavorited!", Icon.Check);- ev.emit(`refreshFavorites`);- });+ (item.type === "notes"+ ? db.notes.note(item.id)+ : db.notebooks.notebook(item.id)+ )+ .favorite()+ .then(() => {+ let itemType = item.type[0] + item.type.substring(1);+ showSnack(itemType + " Unfavorited!", Icon.Check);+ ev.emit(`refreshFavorites`);+ });}});}@@ -40,14 +40,12 @@ const menuItems = item => [).then(res => {if (res) {let itemType = item.type[0] + item.type.substring(1);- itemType === "notes"- ? db.notes.delete([item])- : db.notebooks- .delete([item]) /*db["delete" + itemType]([item])*/- .then(() => {- showSnack(itemType + " Deleted!", Icon.Trash);- ev.emit(`refreshFavorites`);- });+ (itemType === "notes" ? db.notes : db.notebooks)+ .delete(item.id)+ .then(() => {+ showSnack(itemType + " Deleted!", Icon.Trash);+ ev.emit(`refreshFavorites`);+ });}});}@@ -58,7 +56,7 @@ function Favorites() {return (<ListItemtype="Favorites"- getItems={db.notes.favorites /*db.getFavorites.bind(db)*/}+ getItems={db.notes.favorites}menu={{ menuItems, dropdownRefs }}button={undefined}/>diff --git a/apps/web/src/views/Notebooks.js b/apps/web/src/views/Notebooks.jsindex 473767a25..bebb7f006 100644--- a/apps/web/src/views/Notebooks.js+++ b/apps/web/src/views/Notebooks.js@@ -11,7 +11,6 @@ const Notebooks = props => {const [notebooks, setNotebooks] = useState([]);useEffect(() => {function onRefresh() {- console.log(db.notebooks.all);setNotebooks(db.notebooks.all);}onRefresh();@@ -41,10 +40,9 @@ const Notebooks = props => {props.navigator.navigate("notes", {title: notebook.title,subtitle: topic.title,- //notes: db.notebooks.notebook(notebook.dateCreated, topic.title)notes: db.notebooks.notebook(notebook.id)- .topics.topic(topic.title)+ .topics.topic(topic.title).all})}/>@@ -62,15 +60,13 @@ const Notebooks = props => {title,description,topics- }) /*addNotebook({ title, description, topics }))*/+ })) {- setNotebooks(db.notebooks.all /*db.getNotebooks()*/);+ setNotebooks(db.notebooks.all);setOpen(false);} else {showSnack("Please fill out the notebook title.");}-- console.log(db.notebooks.notebook());}}close={() => {setOpen(false);diff --git a/apps/web/src/views/Topics.js b/apps/web/src/views/Topics.jsindex f588197d7..e947cabd6 100644--- a/apps/web/src/views/Topics.js+++ b/apps/web/src/views/Topics.js@@ -18,9 +18,7 @@ const Topics = props => {subtitle: topic.title,notes: db.notebooks.notebook(props.notebook.id)- .topics.topic(- topic.title- ) /*db.getTopic(props.notebook.dateCreated, topic.title)*/+ .topics.topic(topic.title).all});}}/>diff --git a/apps/web/src/views/Trash.js b/apps/web/src/views/Trash.jsindex 257091630..80215168d 100644--- a/apps/web/src/views/Trash.js+++ b/apps/web/src/views/Trash.js@@ -14,12 +14,11 @@ const menuItems = item => [Icon.Star,"Restore",`Are you sure you want to restore this item to ${item.type}?`- ).then(res => {+ ).then(async res => {if (res) {let itemType = item.type[0] + item.type.substring(1);showSnack(itemType + " Restored", Icon.Check);- //db.restoreItem(item.dateCreated);- db.trash.restore(item.id);+ await db.trash.restore(item.id);ev.emit(`refreshTrash`);}});@@ -33,11 +32,11 @@ const menuItems = item => [Icon.Star,"Delete",`Are you sure you want to permanently delete this item?`- ).then(res => {+ ).then(async res => {if (res) {let itemType = item.type[0] + item.type.substring(1);showSnack(itemType + "Permanently Deleted!", Icon.Trash2);- //place permanent delete here+ await db.trash.delete(item.id);ev.emit(`refreshTrash`);}});@@ -49,12 +48,12 @@ function Trash() {return (<ListViewtype="Trash"- getItems={db.trash.all /*db.getTrash.bind(db)*/}+ getItems={db.trash.al}menu={{ menuItems, dropdownRefs }}button={{content: "Clear Trash",icon: Icon.Trash2,- onClick: () => db.trash.clear() /*db.clearTrash()*/+ onClick: async () => await db.trash.clear()}}/>);diff --git a/apps/web/yarn.lock b/apps/web/yarn.lockindex 49e4e311a..dfd1fa6b0 100644--- a/apps/web/yarn.lock+++ b/apps/web/yarn.lock@@ -6885,11 +6885,6 @@ node-fetch@^1.0.1:encoding "^0.1.11"is-stream "^1.0.1"-node-fetch@^2.6.0:- version "2.6.0"- resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.0.tgz#e633456386d4aa55863f676a7ab0daa8fdecb0fd"- integrity sha512-8dG4H5ujfvFiqDmVu9fQ5bOHUC15JMjMY/Zumv26oOvvVJjM67KF8koCWIabKQ1GJIa9r2mMZscBq/TbdOcmNA==-version "0.9.0"resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.9.0.tgz#d624050edbb44874adca12bb9a52ec63cb782579"@@ -7020,13 +7015,11 @@ normalize-url@^3.0.0, normalize-url@^3.0.1:"notes-core@https://github.com/thecodrr/notes-core.git":version "1.1.0"- resolved "https://github.com/thecodrr/notes-core.git#80e2c67fa8c9105db42ddac62e6054b139d9ad68"+ resolved "https://github.com/thecodrr/notes-core.git#e591bdeff6852a104ff0db86a0235a95dfbd1fa3"dependencies:fast-sort "^2.0.1"fuzzysearch "^1.0.3"- node-fetch "^2.6.0"qclone "^1.0.4"- teleport-javascript "^1.0.0"transfun "^1.0.2"npm-bundled@^1.0.1:@@ -9983,11 +9976,6 @@ tar@^4:safe-buffer "^5.1.2"yallist "^3.0.3"-teleport-javascript@^1.0.0:- version "1.0.0"- resolved "https://registry.yarnpkg.com/teleport-javascript/-/teleport-javascript-1.0.0.tgz#c9397fad598d662027e4d3a5fa7e7da1c8361547"- integrity sha512-j1llvWVFyEn/6XIFDfX5LAU43DXe0GCt3NfXDwJ8XpRRMkS+i50SAkonAONBy+vxwPFBd50MFU8a2uj8R/ccLg==-[email protected], terser-webpack-plugin@^1.4.1:version "1.4.1"resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.4.1.tgz#61b18e40eaee5be97e771cdbb10ed1280888c2b4"