From a24c56a9d5485c855cf4dc1240b53c12cba30d06 Mon Sep 17 00:00:00 2001 From: zadam Date: Mon, 20 Mar 2023 23:11:32 +0100 Subject: [PATCH] fixes --- src/becca/entities/bnote.js | 8 ++++++-- src/public/app/components/root_command_executor.js | 8 ++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/becca/entities/bnote.js b/src/becca/entities/bnote.js index d75325d77..2b153588e 100644 --- a/src/becca/entities/bnote.js +++ b/src/becca/entities/bnote.js @@ -1077,13 +1077,17 @@ class BNote extends AbstractBeccaEntity { /** @returns {BAttachment[]} */ getAttachments() { - return sql.getRows("SELECT * FROM attachments WHERE noteId = ? AND isDeleted = 0", [this.noteId]) + return sql.getRows(` + SELECT attachments.* + FROM attachments + WHERE parentId = ? + AND isDeleted = 0`, [this.noteId]) .map(row => new BAttachment(row)); } /** @returns {BAttachment|undefined} */ getAttachmentByName(name) { - return sql.getRows("SELECT * FROM attachments WHERE noteId = ? AND name = ? AND isDeleted = 0", [this.noteId, name]) + return sql.getRows("SELECT * FROM attachments WHERE parentId = ? AND name = ? AND isDeleted = 0", [this.noteId, name]) .map(row => new BAttachment(row)) [0]; } diff --git a/src/public/app/components/root_command_executor.js b/src/public/app/components/root_command_executor.js index bac07af70..930cda706 100644 --- a/src/public/app/components/root_command_executor.js +++ b/src/public/app/components/root_command_executor.js @@ -120,4 +120,12 @@ export default class RootCommandExecutor extends Component { await appContext.tabManager.openContextWithNote(notePath, { activate: true, viewMode: 'source' }); } } + + async showAttachmentsCommand() { + const notePath = appContext.tabManager.getActiveContextNotePath(); + + if (notePath) { + await appContext.tabManager.openContextWithNote(notePath, { activate: true, viewMode: 'attachments' }); + } + } }