Skip to content

Commit

Permalink
fix: show message when upload a non-task block to todoist
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenull committed Jul 9, 2022
1 parent 5903f2e commit c5497ce
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/helper/transform.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export const transformBlockToEvent = async (block: BlockEntity, settings: ISetti
const time = getEventTimeInfo(block)
const pomodoros = getPomodoroInfo(block.content, block.format)
const isMilestone = judgeIsMilestone(block)
const projectPage = block.refs.find(ref => ref.originalName === block.properties?.project?.[0])
const projectPage = block.refs?.find(ref => ref.originalName === block.properties?.project?.[0])
const isJournal = projectPage
? Boolean(projectPage?.journalDay)
: Boolean(page?.journalDay)
Expand Down
4 changes: 2 additions & 2 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,9 @@ if (isDevelopment) {
const settings = getInitalSettings()
const { todoist } = settings
const block = await logseq.Editor.getBlock(uuid)
if (!block?.marker) return logseq.App.showMsg('This block is not a task', 'error')
if (block?.properties?.todoistId) return logseq.App.showMsg('This task has already been uploaded,\nplease do not upload it again', 'error')
const event = await transformBlockToEvent(block!, settings)
if (!event.marker) return logseq.App.showMsg('This block is not a task', 'error')
if (event.properties?.todoistId) return logseq.App.showMsg('This task has already been uploaded', 'warning')

let params: AddTaskArgs = { content: event.addOns.contentWithoutTime?.split('\n')?.[0] }
if (event.addOns.allDay === true) params.dueDate = dayjs(event.addOns.start).format('YYYY-MM-DD')
Expand Down

0 comments on commit c5497ce

Please sign in to comment.