Skip to content

Commit

Permalink
fix: 🐛 nOW task transfer to TODO task
Browse files Browse the repository at this point in the history
should recognize logseq's workflow configration

closed #262
  • Loading branch information
haydenull committed May 29, 2024
1 parent 1f4d58e commit d74454c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/Agenda3/helpers/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export const createTaskBlock = async (taskInfo: CreateAgendaTask) => {
})
// const
const content = [
`TODO ${title}`,
`${getTodoTag()} ${title}`,
start ? `SCHEDULED: <${start.format(allDay ? SCHEDULED_DATE_FORMATTER : SCHEDULED_DATETIME_FORMATTER)}>` : null,
deadline
? `DEADLINE: <${deadline.value.format(
Expand Down Expand Up @@ -266,7 +266,7 @@ export const updateTaskBlock = async (taskInfo: AgendaTaskWithStartOrDeadline &
* toggle task status
*/
export const updateBlockTaskStatus = async (taskInfo: AgendaEntity, status: AgendaEntity['status']) => {
const todoTag = status === 'done' ? 'DONE' : 'TODO'
const todoTag = status === 'done' ? 'DONE' : getTodoTag()
const rawTodoTag = taskInfo.rawBlock.marker
if (!rawTodoTag) {
message.error('This is not a todo block')
Expand Down Expand Up @@ -462,7 +462,7 @@ export function updateBlockDeadline(blockContent: string, deadline?: AgendaEntit
* update title
*/
export function updateBlockTaskTitle(blockContent: string, title: string, status: 'done' | 'todo') {
const todoTag = status === 'done' ? 'DONE' : 'TODO'
const todoTag = status === 'done' ? 'DONE' : getTodoTag()
return blockContent
.split('\n')
.map((line, index) => {
Expand Down Expand Up @@ -532,7 +532,7 @@ export const createObjectiveBlock = async (objective: CreateObjectiveForm) => {
const AGENDA_DRAWER = genAgendaDrawerText({
objective: objectiveInfo,
})
const content = [`TODO ${title}`, AGENDA_DRAWER].filter(Boolean).join('\n')
const content = [`${getTodoTag()} ${title}`, AGENDA_DRAWER].filter(Boolean).join('\n')
const block = await logseq.Editor.insertBlock((await createTodayJournalPage()).uuid, content, {
isPageBlock: true,
customUUID: await logseq.Editor.newBlockUUID(),
Expand All @@ -553,3 +553,8 @@ export const updateObjectiveBlock = async (objective: AgendaObjective) => {
await updateBlock(id, content2)
return logseq.Editor.getBlock(id)
}

/** get todo tag */
export function getTodoTag() {
return window.logseqAppUserConfigs?.preferredWorkflow === 'now' ? 'LATER' : 'TODO'
}
2 changes: 2 additions & 0 deletions src/Agenda3/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ const Dashboard = () => {
// get tasks and projects
useEffect(() => {
const handleWindowFocus = () => {
// 更新 logseqAppUserConfigs
logseq.App.getUserConfigs().then((res) => (window.logseqAppUserConfigs = res))
// 在浏览器获得焦点时刷新数据
loadData()
}
Expand Down

0 comments on commit d74454c

Please sign in to comment.