Skip to content

Commit

Permalink
feat: Support setting the position of the block corresponding to todoist
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenull committed Aug 16, 2022
1 parent a13fb53 commit d9ab085
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/helper/todoist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,16 @@ export const isEventNeedUpdate = (event: IEvent, task: Task) => {
}

export const createBlock = async (task: Task, dateFormat: string) => {
const { todoist } = getInitalSettings()
const date = task.due?.datetime || task.due?.date
const journalName = format(dayjs().valueOf(), dateFormat)
const page = await logseq.Editor.createPage(journalName, {}, { journal: true })

let page
if (todoist?.position) {
page = await logseq.Editor.getPage(todoist.position)
} else {
const journalName = format(dayjs().valueOf(), dateFormat)
page = await logseq.Editor.createPage(journalName, {}, { journal: true })
}

let content = task.content
const logseqPriority = PRIORITY_MAP[task.priority]
Expand Down
1 change: 1 addition & 0 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ if (isDevelopment) {
}
if (event.addOns.allDay === true) params.dueDate = dayjs(event.addOns.start).format('YYYY-MM-DD')
if (event.addOns.allDay === false) params.dueDatetime = dayjs.utc(event.addOns.start).format()
if (!event.rawTime) params.dueString = 'no due date'
if (event.addOns.status === 'done' && task?.completed === false) return closeTask(todoistId)
if (event.addOns.status !== 'done' && task?.completed === true) return reopenTask(todoistId)
updateTask(todoistId, params)
Expand Down
18 changes: 17 additions & 1 deletion src/pages/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,13 @@ const Settings: React.FC<{
<Form.Item label="Log Key" tooltip="Interstitial Journal">
<div className="flex items-center justify-between">
<Form.Item noStyle name={['logKey', 'id']} rules={[{ required: true }]}>
<Input style={{ width: '240px' }} />
<Select
style={{ width: '240px' }}
options={pageOptions}
showSearch
optionFilterProp="label"
filterOption={(input, option) => (option?.label as string)?.toLowerCase()?.includes(input?.toLowerCase())}
/>
</Form.Item>
<Form.Item name={['logKey', 'bgColor']} noStyle rules={[{ required: true }]}>
<ColorPicker text="background" />
Expand Down Expand Up @@ -468,6 +474,16 @@ const Settings: React.FC<{
<Form.Item label="Todoist label for new logseq events" name={['todoist', 'label']} labelCol={{ span: 8 }}>
<Select placeholder="Please select todoist label" options={todoistLabelOptions} />
</Form.Item>
<Form.Item label="Logseq block position" name={['todoist', 'position']} labelCol={{ span: 8 }}>
<Select
placeholder="Please select position page"
options={pageOptions}
allowClear
showSearch
optionFilterProp="label"
filterOption={(input, option) => (option?.label as string)?.toLowerCase()?.includes(input?.toLowerCase())}
/>
</Form.Item>
</div>
</Form>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/util/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export type ISettingsForm = {
sync?: number
project?: number
label?: number
position?: string
},
}
export type IQueryWithCalendar = {
Expand Down

0 comments on commit d9ab085

Please sign in to comment.