Skip to content

Commit

Permalink
fix: Always get current block content
Browse files Browse the repository at this point in the history
Use getEditingBlockContent instead of getCurrentBlock to always get the latest value. Get's rid of an issue where sometimes Jira issue key existed but wasn't detected.
  • Loading branch information
adyscorpius committed May 21, 2024
1 parent b8b26eb commit e5abaa6
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,19 @@ async function main() {
async function updateJiraIssue(useSecondOrg: boolean = false): Promise<void> {
try {
const currentBlock = await logseq.Editor.getCurrentBlock();
const value = await logseq.Editor.getEditingBlockContent(); // This has more current content (whereas currentBlock.content is stale)

if (!currentBlock?.content) {
logseq.UI.showMsg("Couldn't find a valid Jira issue key.", 'error');
throw new Error("Couldn't find a valid Jira issue key.");
if ( currentBlock === null) {
throw new Error('Select a block before running this command');
}

const value = currentBlock.content;
const uuid = currentBlock.uuid;

const uuid = currentBlock?.uuid;

const issuesList = extractIssues(value);

if (!issuesList || issuesList.length < 1) {
logseq.UI.showMsg("Couldn't find any Jira issues in this block.", 'error');
return;
logseq.UI.showMsg("Couldn't find any Jira issues.", 'error');
throw new Error("Couldn't find a valid Jira issue key.");
}

const issues = await getIssues(issuesList, useSecondOrg);
Expand Down

0 comments on commit e5abaa6

Please sign in to comment.