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: crash when deleting a note in topic (#63)
thecodrreecaace64c83
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.jsindex 646d65c7f..4cd7b52aa 100644--- a/apps/web/src/components/note/index.js+++ b/apps/web/src/components/note/index.js@@ -10,7 +10,7 @@ import { store, useStore } from "../../stores/note-store";import { store as editorStore } from "../../stores/editor-store";const dropdownRefs = [];-const menuItems = (note, index, groupIndex) => [+const menuItems = (note, index) => [{title: note.notebook ? "Move" : "Add to",onClick: async () => {@@ -39,7 +39,7 @@ const menuItems = (note, index, groupIndex) => ["Are you sure you want to delete this note?").then(async res => {if (res) {- await store.getState().delete(note.id, { index, groupIndex });+ await store.getState().delete(note.id);}});}@@ -47,7 +47,7 @@ const menuItems = (note, index, groupIndex) => [];function Note(props) {- const { item, index, groupIndex } = props;+ const { item, index } = props;const note = item;const selectedNote = useStore(store => store.selectedNote);const isOpened = selectedNote === note.id;@@ -72,7 +72,7 @@ function Note(props) {}pinned={note.pinned}menuData={note}- menuItems={menuItems(note, index, groupIndex)}+ menuItems={menuItems(note, index)}dropdownRefs={dropdownRefs}/>);diff --git a/apps/web/src/stores/note-store.js b/apps/web/src/stores/note-store.jsindex 5ea543512..b868d9a2d 100644--- a/apps/web/src/stores/note-store.js+++ b/apps/web/src/stores/note-store.js@@ -1,6 +1,5 @@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 = {@@ -62,17 +61,11 @@ function noteStore(set, get) {state.selectedNotes = [];});},- delete: async function(id, info) {+ delete: async function(id) {await db.notes.delete(id);- set(state => {- state.notes.items.splice(info.index, 1);- state.notes.groupCounts[info.groupIndex]--;- if (state.notes.groupCounts[info.groupIndex] <= 0) {- state.notes.groups.splice(info.groupIndex, 1);- state.notes.groupCounts.splice(info.groupIndex, 1);- }- trashStore.getState().refresh();- });+ const state = get();+ state.setSelectedContext(state.selectedContext);+ state.refresh();const editorState = editorStore.getState();if (editorState.session.id === id) {editorState.newSession();