Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: #68 & #64

thecodrr62cfb6261d1a
diff --git a/apps/web/src/common/selectionoptions.js b/apps/web/src/common/selectionoptions.js
index d56d7b1df..516194135 100644
--- a/apps/web/src/common/selectionoptions.js
+++ b/apps/web/src/common/selectionoptions.js
@@ -2,6 +2,7 @@ import * as Icon from "react-feather";
import { store as appStore } from "../stores/app-store";
import { store as notesStore } from "../stores/note-store";
import { store as nbStore } from "../stores/notebook-store";
+import { store as editorStore } from "../stores/editor-store";
import { db } from "./index";
import { showMoveNoteDialog } from "../components/dialogs/movenotedialog";
@@ -21,7 +22,16 @@ function createOptions(options = []) {
const DeleteOption = createOption(Icon.Trash2, async function(state) {
const item = state.selectedItems[0];
- const items = state.selectedItems.map(item => item.id);
+ var isAnyNoteOpened = false;
+ const editorState = editorStore.getState();
+ const items = state.selectedItems.map(item => {
+ if (item.id === editorState.session.id) isAnyNoteOpened = true;
+ return item.id;
+ });
+
+ if (isAnyNoteOpened) {
+ editorState.newSession();
+ }
if (item.type === "note") {
await db.notes.delete(...items);
diff --git a/apps/web/src/stores/note-store.js b/apps/web/src/stores/note-store.js
index 2f599c01a..5ea543512 100644
--- a/apps/web/src/stores/note-store.js
+++ b/apps/web/src/stores/note-store.js
@@ -73,6 +73,10 @@ function noteStore(set, get) {
}
trashStore.getState().refresh();
});
+ const editorState = editorStore.getState();
+ if (editorState.session.id === id) {
+ editorState.newSession();
+ }
},
pin: async function(note) {
await db.notes.note(note).pin();