diff --git a/src/features/parse/semi-auto.ts b/src/features/parse/semi-auto.ts index e17050f..6201e77 100644 --- a/src/features/parse/semi-auto.ts +++ b/src/features/parse/semi-auto.ts @@ -44,11 +44,14 @@ export const semiAutoParse = async ( if ( content.includes(`\`${scheduledChar}${parsedText}\``) || content.includes(`\`${deadlineChar}${parsedText}\``) - ) + ) { return content - if (scheduledChar === 'NA' || deadlineChar === 'NA') { + } + + if (scheduledChar === 'NA' && deadlineChar === 'NA') { return content } + const scheduledOrDeadline = content.includes(scheduledChar) ? 'SCHEDULED' : 'DEADLINE' diff --git a/src/index.tsx b/src/index.tsx index a4ec9cd..eb9a324 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -14,18 +14,20 @@ const main = async () => { handlePopup() // CHeck if any of the special characters are clashing - logseq.onSettingsChanged(async () => { + logseq.onSettingsChanged(() => { const { dateChar, scheduledChar, deadlineChar } = logseq.settings! - const { size } = new Set([dateChar, scheduledChar, deadlineChar]) - if (size === 3) return - if (size === 2) { - if (dateChar == scheduledChar && dateChar == 'NA') return - if (dateChar == deadlineChar && dateChar == 'NA') return - if (scheduledChar == deadlineChar && scheduledChar == 'NA') return + const specialChars = [dateChar, scheduledChar, deadlineChar] + const uniqueChars = new Set(specialChars) + let hasClash = false + if (uniqueChars.size == 1 && !uniqueChars.has('NA')) { + hasClash = true + } + if (uniqueChars.size == 2 && !uniqueChars.has('NA')) { + hasClash = true + } + if (hasClash) { + logseq.UI.showMsg('Special characters clash', 'error') } - if (size === 1 && [dateChar, scheduledChar, deadlineChar].includes('NA')) - return - await logseq.UI.showMsg('Fix clashing special characters', 'warning') }) // FEATURE: Go to date