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: sync favorite & pin state between properties and navigator (#11)
Muhammad Ali213a15ce0954
diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.jsindex c15930ba9..2b5b5d903 100644--- a/apps/web/src/components/editor/index.js+++ b/apps/web/src/components/editor/index.js@@ -82,12 +82,26 @@ export default class Editor extends React.Component {ev.addListener("onNewNote", this.onNewNote.bind(this));ev.addListener("onOpenNote", this.onOpenNote.bind(this));ev.addListener("onClearNote", this.onClearNote.bind(this));+ ev.addListener("onNoteFavorited", this.onNoteFavorite.bind(this));+ ev.addListener("onNotePinned", this.onNotePin.bind(this));}componentWillUnmount() {ev.removeListener("onNewNote", this.onNewNote.bind(this));ev.removeListener("onOpenNote", this.onOpenNote.bind(this));ev.removeListener("onClearNote", this.onClearNote.bind(this));+ ev.removeListener("onNoteFavorited", this.onNoteFavorite.bind(this));+ ev.removeListener("onNotePinned", this.onNotePin.bind(this));+ }++ onNoteFavorite(favorite, id) {+ if (id && id !== this.id) return;+ this.setState({ favorite });+ }++ onNotePin(pinned, id) {+ if (id && id !== this.id) return;+ this.setState({ pinned });}onNewNote(show = true, cb = null) {@@ -142,8 +156,8 @@ export default class Editor extends React.Component {content,title: this.title,id: this.id,- favorite: this.favorite,- pinned: this.pinned,+ favorite: this.state.favorite,+ pinned: this.state.pinned,colors: this.state.colors//TODO add tags once the database is done};diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.jsindex c9923d223..47bf1c7bd 100644--- a/apps/web/src/components/note/index.js+++ b/apps/web/src/components/note/index.js@@ -20,25 +20,29 @@ const menuItems = note => [},{title: note.pinned ? "Unpin" : "Pin",- onClick: async () =>+ onClick: async () => {db.notes.note(note.id).pin().then(() => {showSnack("Note pinned!", Icon.Check);ev.emit("refreshNotes");- })+ });+ sendNotePinnedEvent(note.pinned, note.id);+ }},{title: note.favorite ? "Unfavorite" : "Favorite",- onClick: async () =>+ onClick: async () => {db.notes.note(note.id).favorite().then(() => {showSnack("Note favorited!", Icon.Check);ev.emit("refreshNotes");- })+ });+ sendNoteFavoriteEvent(note.favorite, note.id);+ }},{ title: "Edit" },{ title: note.locked ? "Remove lock" : "Lock" }, //TODO@@ -74,6 +78,14 @@ function sendOpenNoteEvent(note) {ev.emit("onOpenNote", note);}+function sendNoteFavoriteEvent(favorite, id) {+ ev.emit("onNoteFavorited", favorite, id);+}++function sendNotePinnedEvent(pinned, id) {+ ev.emit("onNotePinned", pinned, id);+}+const Note = ({ item, index }) => {const note = item;return note ? (