Skip to content

Commit

Permalink
fix: semi-auto parse
Browse files Browse the repository at this point in the history
  • Loading branch information
benjypng committed Aug 14, 2024
1 parent 2969ced commit d73dfb2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/features/parse/semi-auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
22 changes: 12 additions & 10 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d73dfb2

Please sign in to comment.