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: sync opened note in list with editor
thecodrrafbc4442607d
diff --git a/apps/web/src/components/editor/react-quill.js b/apps/web/src/components/editor/react-quill.jsindex e68283a0f..ee3d7e644 100644--- a/apps/web/src/components/editor/react-quill.js+++ b/apps/web/src/components/editor/react-quill.js@@ -47,6 +47,7 @@ export default class ReactQuill extends Component {componentDidUpdate() {if (this.props.refresh) {this.quill.setContents(this.props.initialContent);+ console.log(this.props.initialContent);if (!this.props.initialContent.ops.length) return;const text = this.quill.getText();if (text[text.length - 1] !== " ") {diff --git a/apps/web/src/stores/editor-store.js b/apps/web/src/stores/editor-store.jsindex 912d11e45..45384e1c6 100644--- a/apps/web/src/stores/editor-store.js+++ b/apps/web/src/stores/editor-store.js@@ -62,7 +62,7 @@ function editorStore(set, get) {state.session.id = id;notestore.getState().refresh();- // we update favorites only if favorites has changed+ // we update favorites only if favorite has changedif (!oldSession || oldSession.favorite !== session.favorite) {notestore.getState().refreshList(LIST_TYPES.fav);}diff --git a/apps/web/src/stores/note-store.js b/apps/web/src/stores/note-store.jsindex 773f42f1e..e310c05f2 100644--- a/apps/web/src/stores/note-store.js+++ b/apps/web/src/stores/note-store.js@@ -1,6 +1,7 @@import { db } from "../common/index";import createStore from "../common/store";import { store as trashStore } from "./trash-store";+import { store as editorStore } from "./editor-store";const LIST_TYPES = {fav: "favorites"@@ -41,6 +42,7 @@ function noteStore(set, get) {await db.notes.note(note).pin();set(state => {state.notes = db.notes.group(undefined, true);+ syncEditor(note, "pinned");});},favorite: async function(note, index) {@@ -50,14 +52,23 @@ function noteStore(set, get) {index = state.notes.items.findIndex(n => n.id === note.id);if (index < 0) return;}- console.log(index, state.notes.items[index]);state.notes.items[index].favorite = !note.favorite;+ syncEditor(note, "favorite");});get().refreshList(LIST_TYPES.fav);}};}+function syncEditor(note, action) {+ const editorState = editorStore.getState();+ if (editorState.session.id === note.id) {+ editorState.setSession(+ state => (state.session[action] = !state.session[action])+ );+ }+}+const [useStore, store] = createStore(noteStore);export { useStore, store, LIST_TYPES };diff --git a/apps/web/src/views/Notes.js b/apps/web/src/views/Notes.jsindex ff34ccce3..466f78b96 100644--- a/apps/web/src/views/Notes.js+++ b/apps/web/src/views/Notes.js@@ -1,6 +1,5 @@import React from "react";import Note from "../components/note";-import { sendNewNoteEvent } from "../common";import ListContainer from "../components/list-container";const Notes = props => {@@ -10,13 +9,13 @@ const Notes = props => {itemsLength={props.notes.length}button={{content: "Make a new note",- onClick: () =>- sendNewNoteEvent({+ onClick: () => {}+ /* sendNewNoteEvent({colors: [],tags: [],notebook: {},...props.context- })+ }) */}}/>);