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 removing last note from a tag
thecodrrb73b8a3d369e
diff --git a/apps/web/__e2e__/tags.test.js b/apps/web/__e2e__/tags.test.jsindex 1d5339c66..3d2b28535 100644--- a/apps/web/__e2e__/tags.test.js+++ b/apps/web/__e2e__/tags.test.js@@ -48,13 +48,15 @@ async function checkTagPresence(title) {async function createNoteAndCheckPresence(title) {await createNote(NOTE, "notes");- await checkNotePresence("notes");+ const noteSelector = await checkNotePresence("notes");expect(await page.isVisible(new List("note").view("notes").grouped().atIndex(0).tag(title).build())).toBe(true);++ return noteSelector;}async function createTagAndCheckPresence(title) {@@ -199,3 +201,27 @@ test("delete a shortcut of a tag", async ({ page }) => {await page.isVisible(new Menu("navitem").item("helloworld").build())).toBe(false);});++test.only("delete the last note of a tag that is also a shortcut", async ({+ page,+}) => {+ const tagSelector = await createTagAndCheckPresence("helloworld");++ await useContextMenu(tagSelector.build(), async () => {+ await clickMenuItem("createshortcut");+ });++ await page.click(tagSelector.build());++ const noteSelector = await createNoteAndCheckPresence("helloworld");++ await useContextMenu(noteSelector, async () => {+ await clickMenuItem("movetotrash");+ });++ expect(await page.isVisible(noteSelector)).toBe(false);++ await navigateTo("notes");++ expect(await page.inputValue(getTestId("routeHeader"))).toBe("Notes");+});diff --git a/apps/web/src/common/list-profiles.js b/apps/web/src/common/list-profiles.jsindex b312d659d..156c2e25f 100644--- a/apps/web/src/common/list-profiles.js+++ b/apps/web/src/common/list-profiles.js@@ -76,7 +76,12 @@ export default Profiles;function getTags(item) {let tags = item.tags;- if (tags) tags = tags.map((t) => db.tags.tag(t)).slice(0, 3);+ if (tags)+ tags = tags.slice(0, 3).reduce((prev, curr) => {+ const tag = db.tags.tag(curr);+ if (tag) prev.push(tag);+ return prev;+ }, []);return tags || [];}diff --git a/apps/web/src/components/editor/index.js b/apps/web/src/components/editor/index.jsindex 30b65109c..7f37c198e 100644--- a/apps/web/src/components/editor/index.js+++ b/apps/web/src/components/editor/index.js@@ -199,7 +199,7 @@ function Editor({ noteId, nonce }) {onSave={saveSession}sessionId={sessionId}onChange={(content, editor) => {- if (!content || content === "<p><br></pr>") return;+ if (!content || content === "<p><br></p>") return;editorstore.get().setSessionContent({type: "tiny",diff --git a/apps/web/src/components/editor/tinymce.js b/apps/web/src/components/editor/tinymce.jsindex 17244b861..8fc12acf5 100644--- a/apps/web/src/components/editor/tinymce.js+++ b/apps/web/src/components/editor/tinymce.js@@ -124,7 +124,7 @@ const plugins = {pro: "textpattern picker",};-const changeEvents = "change keyup input compositionend paste";+const changeEvents = "change input compositionend paste";function TinyMCE(props) {const {@@ -236,6 +236,7 @@ function TinyMCE(props) {}const onEditorChange = debounce((e) => {+ console.log("onEditorChange", e);if (!editor.getHTML) return;editor.getHTML().then((html) => {onChange(html, editor);diff --git a/apps/web/src/stores/note-store.js b/apps/web/src/stores/note-store.jsindex c1e321fb2..79467ab81 100644--- a/apps/web/src/stores/note-store.js+++ b/apps/web/src/stores/note-store.js@@ -69,14 +69,16 @@ class NoteStore extends BaseStore {};delete = async (id) => {+ const { session, clearSession } = editorStore.get();+ if (session && session.id === id) {+ await clearSession();+ }+await db.notes.delete(id);- this.refreshContext();+this.refresh();+ appStore.refreshMenuPins();appStore.refreshColors();- const { session } = editorStore.get();- if (session.id === id) {- hashNavigate("/notes/create", { addNonce: true });- }};pin = async (id) => {