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
web: reopen notes after permanently deleting an attachment
Abdullah Atta8a6328ef07dc
diff --git a/apps/web/src/stores/attachment-store.ts b/apps/web/src/stores/attachment-store.tsindex b9489161b..67758a12c 100644--- a/apps/web/src/stores/attachment-store.ts+++ b/apps/web/src/stores/attachment-store.ts@@ -118,17 +118,22 @@ class AttachmentStore extends BaseStore<AttachmentStore> {permanentDelete = async (attachment: Attachment) => {try {this._changeWorkingStatus(attachment.hash, "delete");+ const linkedNotes = (+ await db.relations+ .to({ id: attachment.id, type: "attachment" }, "note")+ .get()+ ).map((l) => l.toId);if (await db.attachments.remove(attachment.hash, false)) {await this.get().refresh();- const session = useEditorStore.getState().getActiveSession(); //.id;- if (- session &&- (await db.relations- .to({ id: attachment.id, type: "attachment" }, "note")- .has(session.id))- ) {- useEditorStore.getState().closeSessions(session.id);+ const { sessions, openSession } = useEditorStore.getState();+ for (const session of sessions) {+ if (+ linkedNotes.includes(session.id) ||+ ("note" in session && linkedNotes.includes(session.note.id))+ )+ continue;+ await openSession(session.id, { force: true, silent: true });}}} catch (e) {